【问题标题】:How to disable the last blank line in DatagridView?如何禁用 DatagridView 中的最后一个空白行?
【发布时间】:2010-09-08 06:12:12
【问题描述】:

对于 C# Window Form,有一个名为 DataGridView 的工具。

如果我们用它来显示数据,它会显示一个额外的行。

如果我们有 3 行数据,则显示 4 行。第 4 行是空白行。

我想知道如何禁用它.. 或隐藏它?

【问题讨论】:

    标签: c# datagridview


    【解决方案1】:

    这样做:

    myDataGridView1.AllowUserToAddRows = false
    

    【讨论】:

      【解决方案2】:

      在 DataGridView 属性(控件右上角的小箭头)中取消选中启用添加,或在屏幕右侧的属性窗口中将 AllowUserToAddRows 设置为 False。

      【讨论】:

        【解决方案3】:

        从您的项目 [Design] 视图中单击 DataGridView1 并从 (Properties) 中将其设置为:

        -或者-

        使用此代码:

        DataGridView1.Rows.RemoveAt(DataGridView1.CurrentCell.RowIndex);
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2015-06-20
          • 1970-01-01
          • 1970-01-01
          • 2019-11-21
          • 2011-07-02
          • 2023-04-06
          • 2021-10-08
          • 2018-01-13
          相关资源
          最近更新 更多