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.
Unfortunately, activation email could not send to your email. Please try again.

How to change the header text in GridControl?

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

Article ID: Published Date: Last Revised Date: Platform: Control:
6737 04/27/2016 04/27/2016 Windows Forms GridControl
Did you find this information helpful?
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
Add Comment
You must log in to leave a comment

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.