)
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 assign Column names to the Grid Controls, besides the normally assigned numbered headers?

Platform: WinForms |
Control: GridControl |
Published Date: May 18, 2016 |
Last Revised Date: May 28, 2019

The column header text and row header text are generated by default in the design time itself. Those header text can be changed manually through the following options,

Method 1: Using QueryCellInfo

 The column header text can be changed based on row and column index,

C#

void gridControl2_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    // //Column Name for Grid Control2
    if (e.RowIndex == 0 && e.ColIndex > 0)
        e.Style.Text = "Trial" + " " +  e.ColIndex.ToString();
}

 

VB

Private Sub gridControl2_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
 'Column Name for Grid Control2
 If e.RowIndex = 0 AndAlso e.ColIndex > 0 Then
  e.Style.Text = "Trial" & " " & e.ColIndex.ToString()
 End If
End Sub

 

Showing changed column header text

Method 2: Using BaseStylesMap

The column header text changed based on column header base style.

C#

//Column Name for Grid Control1
gridControl1.BaseStylesMap["Column Header"].StyleInfo.Text = "Test";
 

 

VB

'Column Name for Grid Control1
gridControl1.BaseStylesMap("Column Header").StyleInfo.Text = "Test"
 

 

Showing basestyle map in GridControl

Sample:

GridContolColumnHeader_C#

GridControlColumnHeader_VB

 

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