-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathForm1.vb
96 lines (85 loc) · 2.74 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
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraGrid
Imports MinRowHeightXtraGrid
Imports DevExpress.XtraGrid.Views.Grid
Namespace XtraGridMinRowHeight
Partial Public Class Form1
Inherits Form
Private grid As GridControl
Public Sub New()
InitializeComponent()
End Sub
Private Function CreateItems() As List(Of InvoiceItem)
Dim items As New List(Of InvoiceItem)()
Dim rnd As New Random()
For i As Integer = 0 To 9
Dim counter As Integer = i + 1
items.Add(New InvoiceItem("Item " & counter.ToString(), rnd.Next(300), rnd.Next(20)))
Next i
Return items
End Function
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
Me.grid = New MinRowHeightGridControl()
grid.Dock = DockStyle.Fill
grid.MainView = New MinRowHeightGridView(grid)
Controls.Add(grid)
grid.DataSource = CreateItems()
grid.BringToFront()
End Sub
Private Sub btnFont_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnFont.Click
Dim dialog As New FontDialog()
dialog.Font = CType(grid.MainView, GridView).Appearance.Row.Font
If dialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
CType(grid.MainView, GridView).Appearance.Row.Font = dialog.Font
End If
End Sub
End Class
Public Class InvoiceItem
'INSTANT VB NOTE: The variable name was renamed since Visual Basic does not allow variables and other class members to have the same name:
Private name_Renamed As String
'INSTANT VB NOTE: The variable price was renamed since Visual Basic does not allow variables and other class members to have the same name:
Private price_Renamed As Decimal
'INSTANT VB NOTE: The variable quantity was renamed since Visual Basic does not allow variables and other class members to have the same name:
Private quantity_Renamed As Integer
Public Sub New(ByVal name As String, ByVal price As Decimal, ByVal quantity As Integer)
Me.name_Renamed = name
Me.price_Renamed = price
Me.quantity_Renamed = quantity
End Sub
Public Property Name() As String
Get
Return name_Renamed
End Get
Set(ByVal value As String)
name_Renamed = value
End Set
End Property
Public Property Price() As Decimal
Get
Return price_Renamed
End Get
Set(ByVal value As Decimal)
price_Renamed = value
End Set
End Property
Public Property Quantity() As Integer
Get
Return quantity_Renamed
End Get
Set(ByVal value As Integer)
quantity_Renamed = value
End Set
End Property
Public ReadOnly Property Total() As Decimal
Get
Return Price * Quantity
End Get
End Property
End Class
End Namespace