views:

674

answers:

1

I am setting the width of a WinForm datagridview column to 140 and I am checking the width and it's 100. The grid is wide enough to make all columns wider. Why isn't the column accepting the 140 value? Is there a setting which controls the max width?

MyGrid.Columns["Name"].Width = 140;
int i = MyGrid.Columns["Name"].Width; //why is i = 100?
+1  A: 

Check the MyGrid.Columns["Name"].AutoSizeMode, set it to DataGridViewAutoSizeColumnMode.NotSet

MyGrid.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.NotSet;
Vivek