61 lines
2.5 KiB
VB.net
61 lines
2.5 KiB
VB.net
Public Class frmLookup
|
|
Private _Datasource As New List(Of String)
|
|
|
|
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
For index = 1 To 1000000
|
|
_Datasource.Add($"item-{index}")
|
|
Next
|
|
|
|
Dim oDatatable = GetDatatable(10)
|
|
Dim oSelectedValues = _Datasource.Take(1).ToList()
|
|
|
|
LookupControl.DataSource = oDatatable
|
|
LookupControl.SelectedValues = oSelectedValues
|
|
LookupControl.ReadOnly = False
|
|
|
|
LookupControl21.DataSource = oDatatable
|
|
LookupControl21.SelectedValues = oSelectedValues
|
|
LookupControl21.ReadOnly = True
|
|
|
|
LookupControl22.DataSource = oDatatable
|
|
LookupControl22.SelectedValues = oSelectedValues
|
|
LookupControl22.ReadOnly = False
|
|
LookupControl22.MultiSelect = False
|
|
|
|
LookupControl22.SelectedValues = New List(Of String) From {"", Nothing, "LOL", "Foo"}
|
|
|
|
LookupControl23.DataSource = GetDatatable(100000)
|
|
|
|
AddHandler LookupControl.SelectedValuesChanged, Sub(_sender As Object, SelectedValues As List(Of String))
|
|
MsgBox("Selected Values: " & String.Join(",", SelectedValues.ToArray))
|
|
End Sub
|
|
|
|
AddHandler LookupControl21.SelectedValuesChanged, Sub(_sender As Object, SelectedValues As List(Of String))
|
|
MsgBox("Selected Values: " & String.Join(",", SelectedValues.ToArray))
|
|
End Sub
|
|
|
|
AddHandler LookupControl22.SelectedValuesChanged, Sub(_sender As Object, SelectedValues As List(Of String))
|
|
MsgBox("Selected Values: " & String.Join(",", SelectedValues.ToArray))
|
|
End Sub
|
|
End Sub
|
|
|
|
Private Function GetDatatable(Limit As Integer) As DataTable
|
|
Dim oDatatable As New DataTable
|
|
Dim oColumns As New List(Of DataColumn) From {
|
|
New DataColumn("Col1", GetType(String)),
|
|
New DataColumn("Col2", GetType(String))
|
|
}
|
|
|
|
oDatatable.Columns.AddRange(oColumns.ToArray)
|
|
|
|
For Each Item In _Datasource.Take(Limit)
|
|
Dim oRow = oDatatable.NewRow()
|
|
oRow.Item("Col1") = Item
|
|
oRow.Item("Col2") = Item & "_" & "SomeLong Random(String) !!!111einself"
|
|
oDatatable.Rows.Add(oRow)
|
|
Next
|
|
|
|
Return oDatatable
|
|
End Function
|
|
End Class
|