Back to Devexpress

GridView.GroupLevelStyle Event

windowsforms-devexpress-dot-xtragrid-dot-views-dot-grid-dot-gridview-6ddd805e.md

latest4.0 KB
Original Source

GridView.GroupLevelStyle Event

Enables you to specify custom styles for group rows (and corresponding indents) residing at particular nesting levels.

Namespace : DevExpress.XtraGrid.Views.Grid

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
[DXCategory("Appearance")]
public event GroupLevelStyleEventHandler GroupLevelStyle
vb
<DXCategory("Appearance")>
Public Event GroupLevelStyle As GroupLevelStyleEventHandler

Event Data

The GroupLevelStyle event's data class is GroupLevelStyleEventArgs. The following properties provide information specific to this event:

PropertyDescription
LevelGets the nesting level of group rows whose style is to be specified.
LevelAppearanceGets the appearance settings applied to the group rows located at the current nesting level.

Remarks

Handle the GroupLevelStyle event to provide different styles for group rows and corresponding indents depending on the group row level.

The current grouping level is identified by the GroupLevelStyleEventArgs.Level parameter. Use the GroupLevelStyleEventArgs.LevelAppearance parameter to customize the appearance settings of particular group rows and indents.

csharp
using System.Drawing;

Dictionary<int, Color> GroupLevelColors = new Dictionary<int, Color>() {
    {0, Color.DarkGray},
    {1, Color.Orange}
};
private void gridView1_GroupLevelStyle(object sender, GroupLevelStyleEventArgs e) {
    e.LevelAppearance.BackColor = e.Level % 2 == 0 ? GroupLevelColors[0] : GroupLevelColors[1];
}
vb
Imports System.Drawing

Private GroupLevelColors As New Dictionary(Of Integer, Color)() From {
    {0, Color.DarkGray},
    {1, Color.Orange}
}
Private Sub gridView1_GroupLevelStyle(ByVal sender As Object, ByVal e As GroupLevelStyleEventArgs)
    e.LevelAppearance.BackColor = If(e.Level Mod 2 = 0, GroupLevelColors(0), GroupLevelColors(1))
End Sub

Handle the GridView.CustomDrawGroupRow event to specify styles for individual group rows (or paint each individual group row manually). However, this event does not allow you to customize the appearance of group indents (the regions displayed below group expand buttons when group rows are expanded).

See Also

RowStyle

CustomDrawGroupRow

Appearance and Conditional Formatting

Working with Groups in Code

GridView Class

GridView Members

DevExpress.XtraGrid.Views.Grid Namespace