Resizing column number in datagridview c #

IDE VS2010, C # .net 4.0

I need to resize datagridview columns programmatically, so I wrote the following code:

 internal static void ResizeGridViewColumns1(Control c, int incrColumn = 5)
    {
        DataGridView gv = c as DataGridView;

        foreach (DataGridViewColumn currentColumn in gv.Columns)
        {
           currentColumn.Width +=incrColumn;
        }
    }  

      

above code works for resizing columns for datagridview, but I also want to resize gridNumberColumn (don't know technical term) (see reddish part).
please tell me how to programmatically resize this reddish part.

enter image description here

+3


source to share


1 answer


The "redbox part" is the row header area DataGridView

. There is a special property for the width of this area:RowHeadersWidth

so you need



DataGridView gv = c as DataGridView;
gv.RowHeadersWidth += incrColumn;

      

+1


source







All Articles