-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyGridPainter.cs
42 lines (37 loc) · 1.99 KB
/
MyGridPainter.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Drawing;
using DevExpress.XtraGrid.Drawing;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.Drawing;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
namespace CustomGrid {
public class MyGridPainter : GridPainter {
public MyGridPainter(GridView view) : base(view) { }
protected override void DrawRows(GridViewDrawArgs e) {
base.DrawRows(e);
DrawEmptyAreaLines(e);
}
protected virtual void DrawEmptyAreaLines(GridViewDrawArgs e) {
GridViewRects rects = e.ViewInfo.ViewRects;
Rectangle er = rects.EmptyRows;
if(er.IsEmpty) return;
Pen pen = SystemPens.ControlDark;
if(View.OptionsView.ShowVerticalLines != DevExpress.Utils.DefaultBoolean.False) {
foreach(GridColumnInfoArgs column in e.ViewInfo.ColumnsInfo) {
int x = column.Bounds.Right - 1;
if((column.Column != null && column.Column.Fixed != DevExpress.XtraGrid.Columns.FixedStyle.None) ||
((rects.FixedLeft.IsEmpty || x > rects.FixedLeft.Right) &&
(rects.FixedRight.IsEmpty || x < rects.FixedRight.Left - 3)))
e.Cache.DrawLine(pen, new Point(x, er.Top), new Point(x, er.Bottom));
}
if(!rects.FixedRight.IsEmpty)
e.Cache.DrawLine(pen, new Point(rects.FixedRight.Left - 1, er.Top), new Point(rects.FixedRight.Left - 1, er.Bottom));
}
if(View.OptionsView.ShowHorizontalLines != DevExpress.Utils.DefaultBoolean.False) {
int rowHeight = e.ViewInfo.MinRowHeight;
for(int y = er.Top + rowHeight; y < er.Bottom; y += rowHeight)
e.Cache.DrawLine(pen, new Point(er.Left, y), new Point(rects.DataRectRight.Right - 1, y));
}
}
}
}