Imports System.Globalization
Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraEditors.Repository
Imports DevExpress.XtraGrid.Columns
Imports DigitalData.Controls.LookupGrid

Public Class frmLookup

    Private _Datasource As List(Of String) = New List(Of String) From {"Foo", "Bar", "Baz", "Bart", "Maggie", "Homer"}

    Public Sub New()
        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        'Localizer.Active = New LookupGridLocalizer()
    End Sub

    Private Sub frmLookup_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim oCulture = CultureInfo.CurrentCulture
        Dim oUICulture = CultureInfo.CurrentUICulture

        Dim oTable = GetDatatable(10)

        Dim LookupControl31 As New LookupControl3 With {
            .Location = New Point(10, 10),
            .Size = New Size(300, 27)
        }
        Dim LookupControl32 As New LookupControl3 With {
            .Location = New Point(10, 60),
            .Size = New Size(300, 27)
        }
        Dim LookupControl33 As New LookupControl3 With {
            .Location = New Point(10, 110),
            .Size = New Size(300, 27)
        }
        Dim LookupControl34 As New LookupControl3 With {
            .Location = New Point(10, 160),
            .Size = New Size(300, 27)
        }

        Controls.AddRange({LookupControl31, LookupControl32, LookupControl33, LookupControl34})

        LookupControl31.Properties.DataSource = oTable

        LookupControl32.Properties.MultiSelect = True
        LookupControl32.Properties.DisplayMember = "Col1"
        LookupControl32.Properties.ValueMember = "Col1"
        LookupControl32.Properties.DataSource = oTable

        LookupControl33.Properties.AllowAddNewValues = True
        LookupControl33.Properties.MultiSelect = True
        LookupControl33.Properties.DataSource = oTable

        LookupControl34.Properties.AllowAddNewValues = True
        LookupControl34.Properties.MultiSelect = True

        Dim oEditor As New RepositoryItemLookupControl3 With {
            .DisplayMember = "Col1",
            .ValueMember = "Col1"
        }

        GridControl1.RepositoryItems.Add(oEditor)
        oEditor.DataSource = oTable
        GridView1.Columns.Item(0).ColumnEdit = oEditor
        GridControl1.DataSource = oTable
    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)),
            New DataColumn("Col3", 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"
            oRow.Item("Col3") = Item & "_" & "SomeLong OTHER Random(String) !!!111einself"
            oDatatable.Rows.Add(oRow)
        Next

        Return oDatatable
    End Function
End Class