How to Set the Width of a Column in Windows Forms GridDataBoundGrid(Classic)
9 Dec 2019 / 1 minute to read
In order to change the width of columns in GridDataBoundGrid, you must do the following.
- Set the property grid.AllowResizeToFit to False. This can be done once in the forms constructor or Form.Load event. It will turn off the grids default sizing behavior so that your explicit sizing will work. Otherwise, the default sizing will take precedence. The default sizing uses the width of the header text to size the columns.
- Then, explicitly set the width of the particular columns by using Model.ColWidths collection.
//Sets size of column 3 to 250. this.gridDataBoundGrid1.AllowResizeToFit = false; this.gridDataBoundGrid1.Model.ColWidths = 250;
'Sets size of column 3 to 250. Me.GridDataBoundGrid1.AllowResizeToFit = False Me.GridDataBoundGrid1.Model.ColWidths(3) = 250
Was this page helpful? Yes No
Thank you for your feedback!
Thank you for your feedback and comments. We will rectify this as soon as possible!
An unknown error has occurred. Please try again.
Help us improve this page