35 lines
1.1 KiB
VB.net
35 lines
1.1 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
|
|
LookupControl.ReadOnly = True
|
|
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
|
|
LookupControl.ReadOnly = Not LookupControl.ReadOnly
|
|
End Sub
|
|
End Class
|