This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
CustomGridView.vb
80 lines (72 loc) · 2.95 KB
/
CustomGridView.vb
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
Imports System
Imports System.Drawing
Imports DevExpress.XtraGrid
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid.Views.Base
Namespace CustomPrintPreview.Grid
Public Class CustomGridView
Inherits GridView
Public Sub New(ByVal ownerGrid As GridControl)
MyBase.New(ownerGrid)
End Sub
Public Sub New()
End Sub
Friend Const CustomName As String = "CustomGridView"
Protected Overrides ReadOnly Property ViewName() As String
Get
Return CustomName
End Get
End Property
Protected Overrides ReadOnly Property PrintDesigner() As UserControl
Get
Dim ctrl As New UserControl()
Dim args As GetGridPreviewEventArgs = GetGridPreview()
Dim gvp As New CustomGridViewPrinting(args.GridPreview, args.GroupColumn)
args.GridPreview = Nothing
args.GroupColumn = Nothing
gvp.InitFrame(Me, "GridView", New Bitmap(16, 16))
gvp.Dock = DockStyle.Fill
ctrl.Controls.Add(gvp)
ctrl.Visible = True
ctrl.Dock = DockStyle.Fill
ctrl.Size = gvp.UserControlSize
Return ctrl
End Get
End Property
Private Function GetGridPreview() As GetGridPreviewEventArgs
Dim handler As EventHandler(Of GetGridPreviewEventArgs) = TryCast(Events(fGetGridPreview), EventHandler(Of GetGridPreviewEventArgs))
If handler Is Nothing Then
Return Nothing
End If
Dim args As New GetGridPreviewEventArgs()
handler(Me, args)
Return args
End Function
Public Overrides Sub Assign(ByVal v As BaseView, ByVal copyEvents As Boolean)
BeginUpdate()
Try
MyBase.Assign(v, copyEvents)
If copyEvents Then
AddHandler GetCustomGridPreview, CType(CType(v, CustomGridView).Events(fGetGridPreview), EventHandler(Of GetGridPreviewEventArgs))
End If
Finally
EndUpdate()
End Try
End Sub
Friend Sub FireChangedInternal()
MyBase.FireChanged()
End Sub
Private Shared ReadOnly fGetGridPreview As New Object()
Public Custom Event GetCustomGridPreview As EventHandler(Of GetGridPreviewEventArgs)
AddHandler(ByVal value As EventHandler(Of GetGridPreviewEventArgs))
Events.AddHandler(fGetGridPreview, value)
End AddHandler
RemoveHandler(ByVal value As EventHandler(Of GetGridPreviewEventArgs))
Events.RemoveHandler(fGetGridPreview, value)
End RemoveHandler
RaiseEvent(ByVal sender As System.Object, ByVal e As GetGridPreviewEventArgs)
End RaiseEvent
End Event
End Class
End Namespace