Articles in this section
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 WinForms 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 the 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
AddHandler 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#: Rowheader_C#

VB: Rowheader_VB 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied