2019-04-26 17:20:58 +02:00

38 lines
1.0 KiB
VB.net

Public Class Form1
Private _Datasource As New List(Of String) From {"Foo", "bar", "baz", "quux"}
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim oDatatable = GetDatatable()
Dim oSelectedValues = _Datasource.Take(1).ToList()
LookupControl.DataSource = oDatatable
LookupControl.SelectedValues = oSelectedValues
End Sub
Private Function GetDatatable() As DataTable
Dim oDatatable As New DataTable
Dim oColumns As New List(Of DataColumn) From {
New DataColumn("Col1", GetType(String))
}
oDatatable.Columns.AddRange(oColumns.ToArray)
For Each Item In _Datasource
Dim oRow = oDatatable.NewRow()
oRow.Item("Col1") = Item
oDatatable.Rows.Add(oRow)
Next
Return oDatatable
End Function
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MsgBox(LookupControl.SelectedValues.Count)
End Sub
End Class