且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

以编程方式删除datagrid视图中的行标题

更新时间:2023-12-03 17:01:40

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




I have a datagrid view and i want to remove the row header for all rows...

I am trying to remove the rounded part as shown in belowfigure (Row header)

For that I have written the code below.... but it s not woking....

     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;

     }

would any pls give any sample code for removing row header in datagrid view .....

Many thanks In advance.....

Look for a RowHeadersVisible property on the DataGridView in the designer.