This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
/
Form1.vb
196 lines (183 loc) · 6.98 KB
/
Form1.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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
Imports Microsoft.VisualBasic
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ComponentModel
Imports System.Windows.Forms
Imports System.Data
Imports DevExpress.XtraGrid
Imports DevExpress.XtraGrid.Columns
Imports DevExpress.Utils.Drawing
Imports DevExpress.XtraGrid.Views.Grid
Namespace WindowsApplication1
''' <summary>
''' Summary description for Form1.
''' </summary>
Public Class Form1
Inherits System.Windows.Forms.Form
Private gridControl1 As DevExpress.XtraGrid.GridControl
Private WithEvents gridView1 As DevExpress.XtraGrid.Views.Grid.GridView
Private colCategoryID As DevExpress.XtraGrid.Columns.GridColumn
Private colCategoryName As DevExpress.XtraGrid.Columns.GridColumn
Private colDescription As DevExpress.XtraGrid.Columns.GridColumn
Private colPicture As DevExpress.XtraGrid.Columns.GridColumn
Private repositoryItemTextEdit1 As DevExpress.XtraEditors.Repository.RepositoryItemTextEdit
''' <summary>
''' Required designer variable.
''' </summary>
Private components As System.ComponentModel.Container = Nothing
Public Sub New()
'
' Required for Windows Form Designer support
'
InitializeComponent()
'
' TODO: Add any constructor code after InitializeComponent call
'
End Sub
''' <summary>
''' Clean up any resources being used.
''' </summary>
Protected Overrides Overloads Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If components IsNot Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
#Region "Windows Form Designer generated code"
''' <summary>
''' Required method for Designer support - do not modify
''' the contents of this method with the code editor.
''' </summary>
Private Sub InitializeComponent()
Dim resources As New System.ComponentModel.ComponentResourceManager(GetType(Form1))
Me.gridControl1 = New DevExpress.XtraGrid.GridControl()
Me.gridView1 = New DevExpress.XtraGrid.Views.Grid.GridView()
Me.colCategoryID = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colCategoryName = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colDescription = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colPicture = New DevExpress.XtraGrid.Columns.GridColumn()
Me.repositoryItemTextEdit1 = New DevExpress.XtraEditors.Repository.RepositoryItemTextEdit()
CType(Me.gridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.gridView1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.repositoryItemTextEdit1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
' gridControl1
'
Me.gridControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.gridControl1.Location = New System.Drawing.Point(0, 0)
Me.gridControl1.MainView = Me.gridView1
Me.gridControl1.Name = "gridControl1"
Me.gridControl1.Size = New System.Drawing.Size(653, 327)
Me.gridControl1.TabIndex = 0
Me.gridControl1.ViewCollection.AddRange(New DevExpress.XtraGrid.Views.Base.BaseView() { Me.gridView1})
'
' gridView1
'
Me.gridView1.Columns.AddRange(New DevExpress.XtraGrid.Columns.GridColumn() { Me.colCategoryID, Me.colCategoryName, Me.colDescription})
Me.gridView1.FooterPanelHeight = 45
Me.gridView1.GridControl = Me.gridControl1
Me.gridView1.Name = "gridView1"
Me.gridView1.OptionsView.ShowFooter = True
' Me.gridView1.CustomDrawFooterCell += New DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventHandler(Me.gridView1_CustomDrawFooterCell);
'
' colCategoryID
'
Me.colCategoryID.Caption = "CategoryID"
Me.colCategoryID.FieldName = "CategoryID"
Me.colCategoryID.Name = "colCategoryID"
Me.colCategoryID.SummaryItem.SummaryType = DevExpress.Data.SummaryItemType.Sum
Me.colCategoryID.Visible = True
Me.colCategoryID.VisibleIndex = 0
'
' colCategoryName
'
Me.colCategoryName.Caption = "CategoryName"
Me.colCategoryName.FieldName = "CategoryName"
Me.colCategoryName.Name = "colCategoryName"
Me.colCategoryName.Visible = True
Me.colCategoryName.VisibleIndex = 1
'
' colDescription
'
Me.colDescription.Caption = "Description"
Me.colDescription.FieldName = "Description"
Me.colDescription.Name = "colDescription"
Me.colDescription.Visible = True
Me.colDescription.VisibleIndex = 2
'
' colPicture
'
Me.colPicture.Caption = "Picture"
Me.colPicture.FieldName = "Picture"
Me.colPicture.Name = "colPicture"
Me.colPicture.Visible = True
Me.colPicture.VisibleIndex = 3
'
' repositoryItemTextEdit1
'
Me.repositoryItemTextEdit1.AutoHeight = False
Me.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1"
'
' Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(653, 327)
Me.Controls.Add(Me.gridControl1)
Me.Name = "Form1"
Me.Text = "Form1"
' Me.Load += New System.EventHandler(Me.Form1_Load);
CType(Me.gridControl1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.gridView1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.repositoryItemTextEdit1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
''' <summary>
''' The main entry point for the application.
''' </summary>
<STAThread> _
Shared Sub Main()
Application.Run(New Form1())
End Sub
Private Function CreateTable(ByVal RowCount As Integer) As DataTable
Dim tbl As New DataTable()
tbl.Columns.Add("CategoryName", GetType(String))
tbl.Columns.Add("CategoryID", GetType(Integer))
tbl.Columns.Add("Description", GetType(String))
For i As Integer = 0 To RowCount - 1
tbl.Rows.Add(New Object() { String.Format("Name{0}", i), i, String.Format("Desc{0}", i) })
Next i
Return tbl
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
gridControl1.DataSource = CreateTable(10)
gridView1.Columns.AddField("Dummy")
gridView1.Columns("Dummy").UnboundType = DevExpress.Data.UnboundColumnType.Integer
Dim si As New GridSummaryItem(DevExpress.Data.SummaryItemType.Average, "CategoryID", "")
gridView1.Columns("Dummy").SummaryItem.Assign(si)
gridView1.Columns("Dummy").Visible = False
End Sub
Private Sub gridView1_CustomDrawFooterCell(ByVal sender As Object, ByVal e As DevExpress.XtraGrid.Views.Grid.FooterCellCustomDrawEventArgs) Handles gridView1.CustomDrawFooterCell
Dim view As GridView = TryCast(sender, GridView)
If e.Column Is colCategoryID Then
e.Painter.DrawObject(e.Info)
Dim r As Rectangle = e.Info.Bounds
Dim text As String = e.Info.DisplayText
e.Info.Bounds = New Rectangle(e.Info.Bounds.Left, e.Info.Bounds.Bottom + 1, e.Info.Bounds.Width, e.Info.Bounds.Height)
e.Info.DisplayText = view.Columns("Dummy").SummaryText
e.Painter.DrawObject(e.Info)
e.Handled = True
e.Info.Bounds = r
e.Info.DisplayText = text
Else
If e.Column Is colCategoryName Then
e.Handled = True
End If
End If
End Sub
End Class
End Namespace