DEVEXPRESS GridControl 重绘分组行边框


在使用DEV控件库中的gridcontrol的分组功能时,需要给分组行加一个上边线,将不同的组明显的区隔开来,如下图。

重绘分组行,可实现该需求。此处只用了 AddRowLineInfo 这个方法画线,还有其他几个方法,有需要的话可以继续探索。

 1 private void gridView1_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e)
 2 {
 3     GridGroupRowInfo info = e.Info as GridGroupRowInfo;
 4     if (info == null) return;
 5     if (info.Column.FieldName == "CLASS")  //符合条件的分组行
 6     {
 7         GridGroupRowPainter painter = e.Painter as GridGroupRowPainter;
 8         Rectangle bounds = painter.GetGroupClientBounds(info);
 9         AppearanceObject appearance = new AppearanceObject();
10         appearance.BackColor = Color.Black;
11         info.AddRowLineInfo(bounds.X, bounds.Y-2, bounds.Width, 2, appearance);
12         e.Painter.DrawObject(info);
13     }
14 }

主要参考了以下几个链接:

https://www.devexpress.com/Support/Center/Question/Details/Q424679/gridview-customdrawgrouprow

https://www.cnblogs.com/wangfeng8317/p/4432151.html

https://blog.csdn.net/u011871201/article/details/70271798


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM