New to Telerik UI for WinForms? Start a free 30-day trial
Change TextAlignment and BackColor of group rows
Updated over 6 months ago
To modify the text alignment and the back color in the group rows use the following code snippet:
Formatting group rows
C#
void radGridView1_ViewCellFormatting2(object sender, CellFormattingEventArgs e)
{
if (e.CellElement.RowInfo is GridViewGroupRowInfo)
{
e.CellElement.DrawFill = true;
e.CellElement.BackColor = Color.Aquamarine;
e.CellElement.TextAlignment = ContentAlignment.MiddleRight;
e.CellElement.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
}
else
{
e.CellElement.ResetValue(LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.BackColorProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.TextAlignmentProperty, ValueResetFlags.Local);
e.CellElement.ResetValue(LightVisualElement.GradientStyleProperty, ValueResetFlags.Local);
}
}
Figure 1: Formatting group rows.
