开发者

removing row header in datagrid view programmatically

开发者 https://www.devze.com 2023-04-03 05:44 出处:网络
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 the below figure (Row header)

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 the below figure (Row header)

removing row header in datagrid view programmatically

For that, I have written the code below.... but it's not working...

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

         e.PaintHeader(DataGridViewPaintParts.All
             | DataGridViewPaintParts.Border
             | DataGridViewPaintParts.None
             | DataGridViewPaintParts.SelectionB开发者_JAVA百科ackground
             | DataGridViewPaintParts.ContentBackground);

         e.Handled = true;

     }

Would any pls give any sample code for removing the row header in Datagrid view .....

Many thanks. In advance.....


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

removing row header in datagrid view programmatically


From here:

DataGridView Class

RowHeadersVisible Gets or sets a value indicating whether the column that contains row headers is displayed.

why are you being so mean at you to work with RowPrePaint when you can simply set this property to false?

0

精彩评论

暂无评论...
验证码 换一张
取 消