Category / Section
How to customize the caption text in the grid in WinForms GridGroupingControl?
1 min read
Customize the caption text
To customize
the GroupCaptionCell text, you can make use of QueryCellStyleInfo event.
The caption text can be validated by
using TableCellIdentity.TableCellType change its style.
C#
void hierarchyGrid_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
//to customize the caption cell
if (e.TableCellIdentity.TableCellType == GridTableCellType.GroupCaptionCell)
{
e.Style.HorizontalAlignment = GridHorizontalAlignment.Right;
}
}
VB
Private Sub hierarchyGrid_QueryCellStyleInfo(ByVal sender As Object, ByVal e As GridTableCellStyleInfoEventArgs)
'to customize the caption cell
If e.TableCellIdentity.TableCellType = GridTableCellType.GroupCaptionCell Then
e.Style.HorizontalAlignment = GridHorizontalAlignment.Right
End If
End Sub
The screenshot below shows the caption text customization.
Samples: