FlexGrid provides the DefaultSize property of ColumnCollection class to set the column width across the grid. You can also specify the width of a particular column by setting the Width property of the Column class. Default value of Width property is -1 which indicates that the column is taking width specified by the DefaultSize property. The Width property is also available at design time through the C1FlexGrid Column Editor. For more information on column editor, see Editors.
Use the code below to set the default width of a column of the WinForms FlexGrid.
To adjust the column width according to the text length, FlexGrid provides the AutoSizeCol() and AutoSizeCols() methods. While AutoSizeCol() method automatically adjusts width of the specified column, the AutoSizeCols() method is used for cell ranges.
Following code shows how you can auto adjust the column widths according to the text length in the WinForms FlexGrid.
FlexGrid allows you to set bounds to the column width by using the MinSize and MaxSize properties of ColumnCollection. This feature is especially useful in scenarios such as when AllowResizing property is set to true or while using the AutoSizeCol or AutoSizeCols method.
Specify the bounds of column width in the WinForms FlexGrid using the code below.
Star sizing refers to proportional sizing of grid columns to occupy the available space, so that layout of grid remains same even on resizing. For instance, consider a grid with 5 columns whose star sizes are specified as "*", "3*", "2*", "*" and "*". In this case, first, fourth and fifth column always take the same width and grid allocates thrice the width of first column to the second and twice the width to third column.
FlexGrid provides the StarWidth property of Column class to specify the star sizes of columns. To restrict the widths from getting too narrow or too wide, you can set the MinWidth and MaxWidth properties. These properties are also available through the C1FlexGrid Column Editor. For more information on column editor, see Editors.
Set star sizing or proportional sizing in the WinForms FlexGrid columns using the code below.