A header is a collection of columns that enables displaying data in data grid’s cells. A grid supports one or more headers. When a single header is used, the grid has TreeListView control behavior, just like the Microsoft Windows Explorer.
In programming, headers can be added to the grid by calling Grid.Headers.Add(Header header) method. When a header is added to Grid.Headers collection, a zero-based index is assigned to it in the hierarchy. When you call Header.Add(Column column) method, additional columns are added to a header. After that columns can be accessed with indexer operator. Every header has the following collections of columns:
|Header.VisibleColumns||List of visible columns|
|Header.Columns||List of ALL columns|
|Header.SortedColumns||List of columns, that participate in sorting|
|Header.FixedColumns||List of non-scrollable columns|
|Header.GroupedColumns||List of grouped columns|
The same column can be located in different lists. Almost each of the aforementioned lists has Clear() method, that has a specific action when invoked on a certain collection. Specifically, Header.GroupedColumns.Clear() removes data grouping in header of a grid. To group data you only have to set Column.Grouped property to true. If you set this property to true for multiple columns, it will result in multiple grouping and will fill corresponding collection in the data grid header. Such approach can be used in sorting (Column.SortDirection property). The number of fixed columns is defined by Header.FixedColumns.Count.
Back to .Net Grid features