Articles in this section

How to change the header text in WinForms GridControl?

Change header text

To change the column names by using the following methods in our WinForms GridcControl.

  1. BaseStylesMap
  2. QueryCellInfo
  3. RowStyles

To change the column name by using BaseStylesMap as below.

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

To change the column name by using QueryCellInfo as below.

this.gridControl1.QueryCellInfo += gridControl1_QueryCellInfo;

private void gridControl1_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)
{
    if (e.RowIndex == 0 && e.ColIndex > 0)
    {
        e.Style.Text = "Trial" + e.ColIndex;
    }
}
AddHandler Me.gridControl1.QueryCellInfo, AddressOf gridControl1_QueryCellInfo

Private Sub gridControl1_QueryCellInfo(ByVal sender As Object, ByVal e As GridQueryCellInfoEventArgs)
 If e.RowIndex = 0 AndAlso e.ColIndex > 0 Then
  e.Style.Text = "Trial" & e.ColIndex
 End If
End Sub

To change the column name by using RowStyles as below.

for (int k = 1; k <= gridControl1.ColCount; k++)
{
    this.gridControl1[0, k].CellValue = "Trial" + k;
}
For k As Integer = 1 To gridControl1.ColCount
 Me.gridControl1(0, k).CellValue = "Trial" & k
Next k

The screenshot below shows the change of Header Text in the Grid.


Samples:

C#: Change header text

VB: Change header text

 

Conclusion


I hope you enjoyed learning about how to change the header text in WinForms GridControl.


You can refer to our WinForms GridControl feature tour page to know about its other groundbreaking feature representations and WinForms GridControl documentation, and how to quickly get started for configuration specifications.


For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.


If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

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