GridDataControl allows sorting of table data against one or more columns. When Sorting is applied, the Grid rearranges the data to match with the current sort criteria, in ascending or descending order. The number of columns that can be sorted is unlimited. GridDataControl.ShowSortNumber property enables the visibility of the sorting order of the column at the top right corner of the column HeaderCell. However, when sorting more than 9 columns, the order of the column in the HeaderCell is clipped as shown in the following screenshot.
Figure 1: Clipped Sort number
This happens because sorting more than 9 columns is a rare case, hence, the grid by default, allocates width for displaying sort number of a single digit only. However GridDataControl provides a way to avoid this clipping of sort numbers by customizing the width allocated for the sort numbers in the HeaderCell. The property “SortStringWidth” in the GridDataHeaderCellControl class allows you to set custom width for displaying the sort icon and sort numbers. The default value of this property is 25. Setting values greater than 25 increases the width for displaying the sort numbers in the header cell thereby avoiding the clipping of sort numbers, when sorting more than 9 columns.
The following code example demonstrates how to enable the visibility of sorting order and set SortStringWidth for displaying sort numbers of more than one digit.
The following screenshot illustrates the output of the above code. You can see that the sort numbers of two digits are displayed, without being clipped.
Figure 2: Sort numbers in two digits displayed
|Article ID:||Published Date:||Last Revised Date:||Platform:||Control:||.NET Framework:|