Skip to content

DevExpress-Examples/winforms-grid-keep-groups-expanded

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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;
}

Files to Review

Does this example address your development requirements/objectives?

(you will be redirected to DevExpress.com to submit your response)