Articles in this section
Category / Section

How to change the header text in WinForms GridControl?

1 min read

Change header text

To change the column names by using the following ways.

  1. BaseStylesMap
  2. QueryCellInfo
  3. 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"

 

To change the column name by using QueryCellInfo as below.

C#:

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;
    }
}

 

VB:

Private 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.

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

 

Change the header text in GridControl

Samples:

C#: Change header text

VB: Change header text

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments
Please sign in to leave a comment
Access denied
Access denied