Imports Telerik.WinControls.Data

Public Class RadForm1

    Private Sub RadForm1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'NwindDataSet.Products' table. You can move, or remove it, as needed.
        Me.ProductsTableAdapter.Fill(Me.NwindDataSet.Products)
        'TODO: This line of code loads data into the 'NwindDataSet.Customers' table. You can move, or remove it, as needed.
        Me.CustomersTableAdapter.Fill(Me.NwindDataSet.Customers)


        Me.RadMultiColumnComboBox1.DataSource = Me.ProductsBindingSource
        Me.RadMultiColumnComboBox1.DisplayMember = "ProductName"
        Me.RadMultiColumnComboBox1.ValueMember = "ProductID"
        Me.RadMultiColumnComboBox1.AutoFilter = True
        Me.RadMultiColumnComboBox1.AutoCompleteMode = AutoCompleteMode.Suggest

        Dim compositeFilter As New CompositeFilterDescriptor()
        Dim selectField1 As New FilterDescriptor("ProductName", FilterOperator.Contains, "x")
        Dim selectField2 As New FilterDescriptor("ProductName", FilterOperator.Contains, "z")
        Dim selectField3 As New FilterDescriptor("ProductName", FilterOperator.Contains, "w")
        compositeFilter.FilterDescriptors.Add(selectField1)
        compositeFilter.FilterDescriptors.Add(selectField2)
        compositeFilter.FilterDescriptors.Add(selectField3)
        compositeFilter.LogicalOperator = FilterLogicalOperator.[Or]

        Me.RadMultiColumnComboBox1.EditorControl.FilterDescriptors.Add(compositeFilter)
        Me.RadMultiColumnComboBox1.AutoSizeDropDownToBestFit = True


        AddHandler Me.RadMultiColumnComboBox1.SelectedIndexChanged, RadMultiColumnComboBox1_SelectedIndexChanged
        Me.RadMultiColumnComboBox1.SelectedValue = 49
    End Sub

    Private Function RadMultiColumnComboBox1_SelectedIndexChanged() As Object
        Console.WriteLine(Me.RadMultiColumnComboBox1.SelectedIndex)
    End Function

    Private Sub RadButton1_Click(sender As Object, e As EventArgs) Handles RadButton1.Click
        Me.RadMultiColumnComboBox1.DataSource = Nothing
        Me.RadMultiColumnComboBox1.EditorControl.FilterDescriptors.Clear()

        Me.RadMultiColumnComboBox1.DataSource = Me.CustomersBindingSource
        Me.RadMultiColumnComboBox1.DisplayMember = "ContactName"
        Me.RadMultiColumnComboBox1.ValueMember = "CustomerID"

        Me.RadMultiColumnComboBox1.SelectedValue = "BOLID"
    End Sub
End Class
