Category / Section
How to show the numbered row headers in WinForms GridGroipingControl?
1 min read
Show the numbered row headers
You can number the row headers in the GridGroupingControl by enabling the NumberedRowHeaders property. This property supports only the Header cell type. As the row header of the GridGroupingControl is ColumnHeaderCell cell type, the cell type should be changed to Header to number the row headers. The following code example demonstrates the same.
C#
//Displays the numbered row header. this.gridGroupingControl1.Appearance.AnyHeaderCell.CellType = GridCellTypeName.Header;this.gridGroupingControl1.TableModel.Options.NumberedRowHeaders = true;
VB
'Displays the numbered row header. Me.gridGroupingControl1.Appearance.AnyHeaderCell.CellType = GridCellTypeName.Header Me.gridGroupingControl1.TableModel.Options.NumberedRowHeaders = True
By using PrepareViewStyleInfo Event
Row headers can also be numbered through the PrepareViewStyleInfo event.
C#
//Displays the numbered row header.this.gridGroupingControl1.TableControl.PrepareViewStyleInfo += TableControl_PrepareViewStyleInfo; void TableControl_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e) { if (e.RowIndex >= this.gridGroupingControl1.TableControl.TopRowIndex && e.ColIndex == 0) { e.Style.CellType = GridCellTypeName.Header; e.Style.Text = GridRangeInfo.GetNumericLabel(e.RowIndex - 2); }}
VB
'Displays the numbered row header. Private Me.gridGroupingControl1.TableControl.PrepareViewStyleInfo += AddressOf TableControl_PrepareViewStyleInfo Private Sub TableControl_PrepareViewStyleInfo(ByVal sender As Object, ByVal e As GridPrepareViewStyleInfoEventArgs) If e.RowIndex >= Me.gridGroupingControl1.TableControl.TopRowIndex AndAlso e.ColIndex = 0 Then e.Style.CellType = GridCellTypeName.Header e.Style.Text = GridRangeInfo.GetNumericLabel(e.RowIndex - 2) End If End Sub
The following image shows the GridGroupingControl with numbered row headers.
Samples:
C#: https://www.syncfusion.com/downloads/support/directtrac/general/CS737315718.zip
VB: https://www.syncfusion.com/downloads/support/directtrac/general/VB1023996440.zip