-
Notifications
You must be signed in to change notification settings - Fork 0
/
MyGridControl.cs
93 lines (77 loc) · 3.13 KB
/
MyGridControl.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
using DevExpress.Utils;
using DevExpress.XtraEditors.ViewInfo;
using DevExpress.XtraGrid;
using DevExpress.XtraGrid.Columns;
using DevExpress.XtraGrid.Registrator;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using DevExpress.XtraGrid.Views.Grid.ViewInfo;
using DevExpress.XtraGrid.Views.Printing;
using DevExpress.XtraPrinting;
using System.ComponentModel;
namespace GridBeforePrint
{
[ToolboxItem(true)]
public class MyGridControl : GridControl
{
protected override BaseView CreateDefaultView()
{
return CreateView("MyGridView");
}
protected override void RegisterAvailableViewsCore(InfoCollection collection)
{
base.RegisterAvailableViewsCore(collection);
collection.Add(new MyGridViewInfoRegistrator());
}
}
public class MyGridViewInfoRegistrator : GridInfoRegistrator
{
public override string ViewName { get { return "MyGridView"; } }
public override BaseView CreateView(GridControl grid) { return new MyGridView(grid as GridControl); }
}
public class MyGridView : GridView
{
protected override BaseViewPrintInfo CreatePrintInfoInstance(PrintInfoArgs args)
{
return new MyGridViewPrintInfo(args);
}
public delegate void SampleEventHandler(object sender, SamplePrintEventArgs args);
public delegate void HeaderPainterEventHandler(object sender, HeaderPrintEventArgs args);
public event HeaderPainterEventHandler HeaderPrintEvent;
public event SampleEventHandler SamplePrintEvent;
public void RaiseHeaderPrintEvent(object sender, HeaderPrintEventArgs args)
{
if (HeaderPrintEvent != null)
HeaderPrintEvent(sender, args);
}
public void RaiseSamplePrintEvent(object sender, SamplePrintEventArgs args)
{
if (SamplePrintEvent != null)
SamplePrintEvent(sender, args);
}
public MyGridView() : this(null) { }
public MyGridView(DevExpress.XtraGrid.GridControl grid) : base(grid) { }
public MyGridView(MyGridControl grid) : base(grid) { }
protected override string ViewName { get { return "MyGridView"; } }
protected internal string GoAndGetNonFormattedCaption(string caption)
{
return GetNonFormattedCaption(caption);
}
internal string GoAndGetRowCellDisplayTextCore(int rowHandle, GridColumn column, BaseEditViewInfo bev, object value, bool forGroupRow)
{
return base.GetRowCellDisplayTextCore(rowHandle, column, bev, value, forGroupRow);
}
public HorzAlignment GetHorzAlignment(int rowHandle, GridColumn column, HorzAlignment currentAlignment)
{
return base.GetRowCellDefaultAlignment(rowHandle, column, currentAlignment);
}
}
public class MyGridViewInfo : GridViewInfo
{
public MyGridViewInfo(MyGridView gridView) : base(gridView) { }
protected internal void GoAndUpdateCellAppearanceCore(GridCellInfo cell)
{
base.UpdateCellAppearanceCore(cell);
}
}
}