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 to change the header text in GridControl?

Platform: WinForms |
Control: GridControl |
Published Date: April 27, 2016 |
Last Revised Date: April 27, 2016

To change the column names by using the following ways.

Way1: BaseStylesMap

Way2: QueryCellInfo

Way3: RowStyles

To change the column name by using BaseStylesMap as below.

C#:

gridControl1.BaseStylesMap["Column Header"].StyleInfo.Text="Trial";

 

VB:

gridControl1.BaseStylesMap("Column Header").StyleInfo.Text="Trial"

 

C#:

 

VB:

 

 

C#:

for (int k = 1; k <= gridControl1.ColCount; k++)

{

    this.gridControl1[0, k].CellValue = "Trial" + k;

}

 

VB:

For k As Integer = 1 To gridControl1.ColCount

                Me.gridControl1(0, k).CellValue = "Trial" & k

Next k

 

 

 

 

Sample

C#: Change header text

VB: Change header text

ADD COMMENT
You must log in to leave a comment
Comments
Robert Dickow
Sep 03, 2018

I found that setting the column header text during the QueryCellInfo handler works well. This technique solves my problem. I found that some of the other techniques do not work for me for some reason. For example, as a test I set the GridControl Enter event handler as follows:  In this code the status bar label updates with the word "Howdy" but the grid control column header is unchanged.

// C#` 

private void EnterTest(object sender, EventArgs e)
{
   gridControl[0, 4].CellValue = "Howdy"; // does not alter column header text as expected
   statusStripLabel.Text = "Howdy";  // to visually verify execution of handler
   gridControl.Refresh();  // just to be sure.

}

`

Reply
Mohanraj Gunasekaran [Syncfusion]
Sep 04, 2018

Hi Robert,

 

Thanks for using Syncfusion product.

 

We have tried with your reported scenario in Enter event handler. But, it is working fine as we expected. We suspect that you may tried to change the header text using QueryCellInfo and GridControl[0,4].CellValue property. If you have used both code in your implementation, QueryCellInfo changes will be reflected in GridControl. If you have used different approach, please provide the more information to reproduce the reported scenario. It will be helpful us to proceed further

 

Sample link: http://www.syncfusion.com/downloads/support/directtrac/general/ze/cs-1786788512

 

Regards,

Mohanraj G

Reply

Please sign in to access our KB

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

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