This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Form1.vb
107 lines (89 loc) · 2.93 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
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports DevExpress.XtraGrid.Columns
Namespace GridLookUpEditCBMultipleSelection
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim dt As DataTable = FillDataTable()
myGridLookUpEdit1.Properties.View.OptionsBehavior.AutoPopulateColumns = False
myGridLookUpEdit1.Properties.DataSource = dt
myGridLookUpEdit1.Properties.DisplayMember = "Fruit"
myGridLookUpEdit1.Properties.View.OptionsSelection.MultiSelect = True
myGridLookUpEdit1.Properties.GridSelection = New GridCheckMarksSelection(myGridLookUpEdit1.Properties.View)
myGridLookUpEdit1.Properties.GridSelection.SelectAll(dt.DefaultView)
Dim col As GridColumn = myGridLookUpEdit1.Properties.View.Columns.AddField("Fruit")
col.Visible = True
col.Caption = "Fruit"
Dim bl As New BindingList(Of Customer)()
For i As Integer = 1 To 5
bl.Add(New Customer(i, "Name " & i.ToString()))
Next i
myGridLookUpEdit2.Properties.View.OptionsBehavior.AutoPopulateColumns = False
myGridLookUpEdit2.Properties.DataSource = bl
myGridLookUpEdit2.Properties.DisplayMember = "Name"
myGridLookUpEdit2.Properties.View.OptionsSelection.MultiSelect = True
myGridLookUpEdit2.Properties.GridSelection = New GridCheckMarksSelection(myGridLookUpEdit2.Properties.View)
myGridLookUpEdit2.Properties.GridSelection.SelectAll(bl)
Dim colName As GridColumn = myGridLookUpEdit2.Properties.View.Columns.AddField("Name")
colName.Visible = True
colName.Caption = "Name"
End Sub
Private Function FillDataTable() As DataTable
Dim _dataTable As New DataTable()
Dim col As DataColumn
Dim row As DataRow
col = New DataColumn()
col.ColumnName = "Bool"
col.DataType = System.Type.GetType("System.Boolean")
_dataTable.Columns.Add(col)
col = New DataColumn()
col.ColumnName = "Fruit"
col.DataType = System.Type.GetType("System.String")
_dataTable.Columns.Add(col)
row = _dataTable.NewRow()
row("Fruit") = "Peach"
_dataTable.Rows.Add(row)
row = _dataTable.NewRow()
row("Fruit") = "Apple"
_dataTable.Rows.Add(row)
row = _dataTable.NewRow()
row("Fruit") = "Banana"
_dataTable.Rows.Add(row)
Return _dataTable
End Function
End Class
Public Class Customer
Private id_ As Integer
Public Property ID() As Integer
Get
Return id_
End Get
Set(ByVal value As Integer)
id_ = value
End Set
End Property
Private name_ As String
Public Property Name() As String
Get
Return name_
End Get
Set(ByVal value As String)
name_ = value
End Set
End Property
Public Sub New(ByVal pID As Integer, ByVal pName As String)
ID = pID
Name = pName
End Sub
End Class
End Namespace