In This Topic
About Column Header
The column header is a widget that is represented by the NColumnHeader class and is accessible from the NColumn.Header property. The column header has three child elements - content, filter button and sorting button as demonstrated by the following image:
Column Header Content
The content element of the column header is accessible from the Content property of NColumnHeader. By default the content is a NLabel widget that is automatically recreated when you change the NColumn.Title property. The following code example changes the column title:
Change Column Title |
Copy Code
|
column.Title = "My Column Title";
|
The column header automatically recreates the content element when the Title property has changed. You can however make a custom column header by handling the CreateHeaderContentDelegate delegate:
Custom Column Header |
Copy Code
|
column.CreateHeaderContentDelegate = delegate(NColumn theColumn)
{
NPairBox pairBox = new NPairBox(NResources.Image__16x16_Gender_png, theColumn.Title, ENPairBoxRelation.Box1BeforeBox2);
pairBox.Spacing = 2;
return pairBox;
};
column.UpdateHeaderContent();
|
To force column recreation you can either change the Title property or call the UpdateHeaderContent() method.
Filter Button
The filter button of the column header is accessible from the FilterButton property of NColumnHeader. When clicked this button invokes the Filters Editor, which lets you define filtering rules associated with the column.
The visibility of the filter button is controlled by the NColumnHeader.ShowFilterButton property. The value of this property by default depends on the NColumn.AllowFilter and NGrid.AllowColumnsFilter, so in practice you will more likely prevent the column or the grid from filtering, rather that simply hiding the filter button. See Grid Protection and Column- Protection for more info.
Sorting Button
The sorting button of the column header is accessible from the
SortingButton property of
NColumnHeader. The sorting button symbol indicates the direction of the sorting rule (if any) that is associated with the column (i.e. ascending or descending). Clicking on the sorting button toggles the sorting direction of the sorting rule that is associated with the column. The same is also performed when the user clicks on the column header. See
Sorting for more information about sorting rules and columns.