DevExpress-How to keep all the groups expanded

How to keep all the groups expanded

Description:
I am using the grouping feature of the grid. I would like to have the groups always expanded, and hide the +/- sign displayed at the beginning of the rows. How can I achieve this?

Answer:
This can be implemented by handling the GroupRowCollapsingCustomDrawGroupRow, and EndGrouping events.
By setting the e.Allow parameter of GroupRowCollapsing to false you prevent a group row from being collapsed.

private void gridView1_GroupRowCollapsing(object sender, DevExpress.XtraGrid.Views.Base.RowAllowEventArgs e) {  
    e.Allow = false;  
}  
  

The CustomDrawGroupRow event is used to hide the expand/collapse group row 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;  
}  
  

The ExpandAllGroups method called inside the EndGrouping event handler expands all group rows when a user changes group columns.

  
private void gridView1_EndGrouping(object sender, System.EventArgs e) {  
    (sender as DevExpress.XtraGrid.Views.Grid.GridView).ExpandAllGroups();  
}  
  

dxKB1497.zip

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值