winform单据加强显示

效果如图:
在这里插入图片描述
这里采用了重新绘制网格线(使用CellMeger效果并不理想),显示效果更加简洁清新。
代码如下:

this.gridView1.OptionsView.ShowHorizontalLines = DevExpress.Utils.DefaultBoolean.False;//取消水平线
            this.gridView1.CustomDrawCell += (s, g) =>
            {
                if (g.Column.FieldName == "FBillNo")
                {
                    if (g.RowHandle > 0 && g.DisplayText == this.gridView1.GetRowCellValue(g.RowHandle - 1, "FBillNo").ToString())
                    {
                        g.DisplayText = string.Empty;
                    }
                    else if ((g.RowHandle > 0 && g.DisplayText != this.gridView1.GetRowCellValue(g.RowHandle - 1, "FBillNo").ToString()) || g.RowHandle == this.gridView1.RowCount - 1)
                    {
                        var color = Color.FromArgb(202, 203, 211);
                        Pen pen = new Pen(color, 1);
                        Point point1 = new Point(this.gridControl1.Location.X, g.Bounds.Y - 1);
                        Point point2 = new Point(this.gridControl1.Location.X + this.gridControl1.Width, g.Bounds.Y - 1);
                        g.Cache.DrawLine(pen, point1, point2);
                    }
                }
                else if ("FBillDate,FSupplierNumber,FSupplierName".Contains(g.Column.FieldName))//隐藏其他列
                {
                    if (g.RowHandle > 0 && this.gridView1.GetRowCellValue(g.RowHandle - 1, "FBillNo").ToString() == this.gridView1.GetRowCellValue(g.RowHandle, "FBillNo").ToString())
                    {
                        g.DisplayText = string.Empty;
                    }
                }
            };

猜你喜欢

转载自blog.csdn.net/pxxcsdn/article/details/88398893
今日推荐