How to assign Column names to the Grid Controls, besides the normally assigned numbered headers?
The column header text and row header text are generated by default in the design time itself. Those header text can be changed manually in WinForms GridControl 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
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"
Sample:
I hope you enjoyed learning about how to assign Column names to the Grid Controls, besides the normally assigned numbered headers.
You can refer to our WinForms GridControl’s feature tour page to know about its other groundbreaking feature representations. You can also explore our WinForms GridControl documentation to understand how to present and manipulate data.
For current customers, you can check out our WinForms 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 WinForms GridControl and other WinForms components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!