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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I change the row header to display line numbers instead of the black triangle in GridDataBoundGrid?

Platform: WinForms |
Control: GridDataBoundGrid(Classic) |
Published Date: April 30, 2011 |
Last Revised Date: July 10, 2014

 

You can acheive this by changing the row header basestyle to 'Header' and handling the PrepareViewStyleInfo to set the line numbers. Please refer the below code snippets:

C#

// In the Form Load

private void Form1_Load(object sender, System.EventArgs e)

{

this.gridDataBoundGrid1.DataSource = GetTable();

this.gridDataBoundGrid1.BaseStylesMap["Row Header"].StyleInfo.CellType = "Header";

}

// GridPrepareViewStyleInfo

private void grid_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)

{

if(e.ColIndex == 0 && e.RowIndex > 0)

{

e.Style.Text = e.RowIndex.ToString();

e.Style.Font.Bold = false;

}

}

VB

' In the Form Load

Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load

Me.gridDataBoundGrid1.DataSource = GetTable()

Me.gridDataBoundGrid1.BaseStylesMap("Row Header").StyleInfo.CellType = "Header"

End Sub 'Form1_Load

' GridPrepareViewStyleInfo

Private Sub gridDataBoundGrid1_PrepareViewStyleInfo(sender As Object, e As Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs) Handles gridDataBoundGrid1.PrepareViewStyleInfo

If e.ColIndex = 0 AndAlso e.RowIndex > 0 Then

e.Style.Text = e.RowIndex.ToString()

e.Style.Font.Bold = False

End If

End Sub

Here is the link with both CS and VB samples: http://websamples.syncfusion.com/samples/KB/Grid.Windows/GDBG_NumberedHeader/main.htm

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