WinForms Data Grid - Keep all groups expanded
This example automatically expands all group rows on application startup and hides expand/collapse buttons to prevent users from collapsing group rows.
The GroupRowCollapsing event is handled to prevent users from collapsing group rows:
private void gridView1_GroupRowCollapsing(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e) {
e.Allow = false;
}
The CustomDrawGroupRow event is handled to hide expand/collapse buttons:
private void gridView1_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e) {
DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo info;
info = e.Info as DevExpress.XtraGrid.Views.Grid.ViewInfo.GridGroupRowInfo;
info.ButtonBounds = Rectangle.Empty;
info.GroupText = " " + info.GroupText.TrimStart();
e.Cache.FillRectangle(e.Appearance.GetBackBrush(e.Cache), e.Bounds);
ObjectPainter.DrawObject(e.Cache, e.Painter, e.Info);
e.Handled = true;
}