See Also Send us your Feedback
BeeGrid Basics - Columns

Grid columns are represented with SGColumns collection and each column is represented by SGColumn object. By manipulating these objects, you can add or remove columns and change column attributes. To reference a particular column, you can use column position, column index or column key. 

Column position is a current left-to-right counted position of a column in a grid. Left-most column has position 0 (zero). Column position can be changed when user drags and drops column in a grid. If a column is hidden, its position is not changed. To access column with its position use column collection's At method.

Column index is a unique number that is assigned to a column when it is created. Heading column (column with row selectors) has index with value zero. Data columns indices start with 1. Changing column position does not change its index, but when columns are added or removed from the columns collection or when columns layout is restored (with SetDefinition method), value of the ColIndex property can change. To access column by its index, use Columns(index) syntax.

Column key is a unique, user-defined string that identifies one column. The Key property can be initialized when you use the Add method to create a new column. Column key can not be changed. Use column key to refer to columns when you are not sure that column indices will not be changed and when you want to assign meaningful names to columns. To access column by its key, use Columns(key) syntax.

   

The following list explains how to solve some common column tasks.

To add a column
  • Use column's Add or InsertAt method to add one column.
  • Use column collection's SetDefinition method to initialize all columns in one step.
To remove a column
  • Use the column collection's RemoveAll method to remove all columns.
  • Use column's Remove or the RemoveAt method to remove one column.
To bind a column
  • In the bound data mode, set the AutoFields to true and grid will automatically create columns for all data source fields.
  • Set the column's DBField property to a name of the data source field.
To unbind a column
  • Set the column's DBField property to an empty string.
To hide a column
  • Set the column's Hidden property to True.
  • Set the column's  UserHiding property to sgAllowColHide or sgAllowRowColHide to allow users to hide columns.
To move a column
  • Change the column's Position property.
  • Set the column's UserDragging property to sgAllowColDrag or sgAllowRowColDrag to allow users to move columns.
To size a column 
  • Set the column's Width property.
  • In the bound mode, set the column's AutoResize property to sgAutoResizeColumns or sgAutoResizeRowsAndColumns to fit each column with its contents.
  • Call the AutoSizeColumns method to auto size columns.
  • Set the UserResizing property to sgAllowColResizing or sgAllowRowColResizing to allow the user to size columns.
To change column appearance

See Also

SGColumn | DataColCount | Samples - Appearance | Samples - UserDragging | Samples - Columns Properties