This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
CustomGridControl.vb
117 lines (108 loc) · 4.11 KB
/
CustomGridControl.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.Data.Filtering.Helpers
Imports DevExpress.Data.Filtering
Imports DevExpress.XtraGrid.Views.Grid
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Views.Grid.Drawing
Imports DevExpress.XtraGrid.Views.Grid.ViewInfo
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Registrator
Imports DevExpress.XtraLayout
Imports System.ComponentModel
Imports DevExpress.Utils.Controls
Imports DevExpress.Utils.Serializing
Namespace CustomGridColumn_MaxRowHeight
Public Class CustomGridView
Inherits GridView
Public Sub New()
MyBase.New()
End Sub
Protected Friend Overridable Sub SetGridControlAccessMetod(ByVal newControl As GridControl)
SetGridControl(newControl)
End Sub
Protected Overrides ReadOnly Property ViewName() As String
Get
Return "CustomGridView"
End Get
End Property
Protected Overrides Function CreateOptionsView() As ColumnViewOptionsView
Return New CustomGridOptionsView()
End Function
<Description("Provides access to the View's display options."), Category("Options"), DesignerSerializationVisibility(DesignerSerializationVisibility.Content), XtraSerializableProperty(XtraSerializationVisibility.Content, XtraSerializationFlags.DefaultValue), XtraSerializablePropertyId(LayoutIdOptionsView)>
Public Shadows ReadOnly Property OptionsView() As CustomGridOptionsView
Get
Return TryCast(MyBase.OptionsView, CustomGridOptionsView)
End Get
End Property
End Class
Public Class CustomGridControl
Inherits GridControl
Public Sub New()
MyBase.New()
End Sub
Protected Overrides Sub RegisterAvailableViewsCore(ByVal collection As InfoCollection)
MyBase.RegisterAvailableViewsCore(collection)
collection.Add(New CustomGridInfoRegistrator())
End Sub
Protected Overrides Function CreateDefaultView() As BaseView
Return CreateView("CustomGridView")
End Function
End Class
Public Class CustomGridInfoRegistrator
Inherits GridInfoRegistrator
Public Sub New()
MyBase.New()
End Sub
Public Overrides Function CreateViewInfo(ByVal view As BaseView) As DevExpress.XtraGrid.Views.Base.ViewInfo.BaseViewInfo
Return New CustomGridViewInfo(TryCast(view, GridView))
End Function
Public Overrides ReadOnly Property ViewName() As String
Get
Return "CustomGridView"
End Get
End Property
Public Overrides Function CreateView(ByVal grid As GridControl) As BaseView
Dim view As New CustomGridView()
view.SetGridControlAccessMetod(grid)
Return view
End Function
End Class
Public Class CustomGridViewInfo
Inherits GridViewInfo
Public Sub New(ByVal gridView As GridView)
MyBase.New(gridView)
End Sub
Protected Overrides Function CalcRowAutoHeight(ByVal g As System.Drawing.Graphics, ByVal colInfo As GridColumnsInfo, ByVal rowHandle As Integer, ByVal rowVisibleIndex As Integer, ByVal useCache As Boolean, ByVal level As Integer) As Integer
If CType(View, CustomGridView).OptionsView.MaxRowHeight > 0 Then
Return Math.Min(CType(View, CustomGridView).OptionsView.MaxRowHeight, MyBase.CalcRowAutoHeight(g, colInfo, rowHandle, rowVisibleIndex, useCache, level))
End If
Return MyBase.CalcRowAutoHeight(g, colInfo, rowHandle, rowVisibleIndex, useCache, level)
End Function
End Class
Public Class CustomGridOptionsView
Inherits GridOptionsView
'INSTANT VB NOTE: The variable maxRowHeight was renamed since Visual Basic does not allow variables and other class members to have the same name:
Private maxRowHeight_Renamed As Integer
Public Sub New()
MyBase.New()
maxRowHeight_Renamed = -1
End Sub
<Description("Get or set maximum row height."), DefaultValue(-1), XtraSerializableProperty()>
Public Overridable Property MaxRowHeight() As Integer
Get
Return maxRowHeight_Renamed
End Get
Set(ByVal value As Integer)
If maxRowHeight_Renamed = value Then
Return
End If
Dim prevValue As Integer = maxRowHeight_Renamed
maxRowHeight_Renamed = value
OnChanged(New BaseOptionChangedEventArgs("MaxRowHeight", prevValue, MaxRowHeight))
End Set
End Property
End Class
End Namespace