以编程方式删除数据网格视图中的行标题

Posted

技术标签:

【中文标题】以编程方式删除数据网格视图中的行标题【英文标题】:removing row header in datagrid view programmatically 【发布时间】:2011-11-11 13:45:39 【问题描述】:

我有一个 Datagrid 视图,我想删除所有行的行标题...

我正在尝试删除圆角部分,如下图所示(行标题)

为此,我编写了下面的代码....但它不起作用...

     private void dgvProducts_RowPrePaint(object sender, DataGridViewRowPrePaintEventArgs e)
     
         e.PaintCells(e.ClipBounds, DataGridViewPaintParts.All);

         e.PaintHeader(DataGridViewPaintParts.All
             | DataGridViewPaintParts.Border
             | DataGridViewPaintParts.None
             | DataGridViewPaintParts.SelectionBackground
             | DataGridViewPaintParts.ContentBackground);

         e.Handled = true;

     

请提供任何示例代码以删除 Datagrid 视图中的行标题.....

非常感谢。提前.....

【问题讨论】:

【参考方案1】:

在设计器中的 DataGridView 上查找 RowHeadersVisible 属性。

【讨论】:

【参考方案2】:

从这里开始:

DataGridView Class

RowHeadersVisible 获取或设置一个值,指示是否 显示包含行标题的列。

当你可以简单地将这个属性设置为 false 时,你为什么对你使用 RowPrePaint 如此刻薄?

【讨论】:

以上是关于以编程方式删除数据网格视图中的行标题的主要内容,如果未能解决你的问题,请参考以下文章