)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to show the numbered row headers in WinForms GridGroipingControl?

Platform: WinForms |
Control: GridGroupingControl |
Published Date: September 8, 2015 |
Last Revised Date: December 31, 2019
Tags: rowheader, header

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.

 Show the GridGroupingControl with numbered row headers

 

Samples:

C#: http://www.syncfusion.com/downloads/support/directtrac/general/CS737315718.zip

VB: http://www.syncfusion.com/downloads/support/directtrac/general/VB1023996440.zip

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon