adding an item and clearing all items

2 posts, 0 answers
  1. Simon
    Simon avatar
    7 posts
    Member since:
    Sep 2011

    Posted 21 Sep 2011 Link to this post

    Private Sub LoadSupplierCombo()
            Cursor = Cursors.WaitCursor
            tsstatus.Text = "Loading Suppliers, please wait..."
            '     cbSuppliers..MasterTemplate.AutoGenerateColumns = True
            Dim TicketsDA As SqlDataAdapter
            Dim TicketsDS As DataSet
            Dim TicketsDV As DataView
            Dim SQLString As String = ""
                SQLString = "SELECT     Supplier.SupplierName AS Supplier, Supplier.SupplierAccountNo AS [Account No] " & _
    "FROM         SZTickets INNER JOIN " & _
                         " SZTicketStatus ON SZTickets.statusId = INNER JOIN " & _
                         " SZTicketPriority ON SZTickets.priorityId = INNER JOIN " & _
                         " Supplier ON SZTickets.supplierId = Supplier.SupplierID " & _
    "GROUP BY Supplier.SupplierName, Supplier.SupplierAccountNo " & _
    "ORDER BY Supplier DESC"
                Dim SQLcmd As New SqlCommand(SQLString, cnn1)
                TicketsDA = New SqlDataAdapter(SQLcmd)
                TicketsDS = New DataSet
                TicketsDV = New DataView
                TicketsDA.Fill(TicketsDS, "Suppliers")
                TicketsDV.Table = TicketsDS.Tables("Suppliers")
                cbSuppliers.DataSource = TicketsDV
            Catch ex As Exception
                g_error.DBErrorMsg("Failure to load tickets", SQLString, ex)
            End Try
            Cursor = Cursors.Default
            tsstatus.Text = ""
            Dim columns As RadMultiColumnComboBoxElement = cbSuppliers.MultiColumnComboBoxElement
            For Each column As GridViewDataColumn In columns.Columns
        End Sub


    The above code loads my multi-column list box. However I would like to add <All Suppliers> at the beginning of the list as well as the supplier. I would like this to be the item selected on load.

    Also, I cant find the equivalent command for combobox.items.clear() 

    How do I remove all the items?


  2. Svett
    Svett avatar
    728 posts

    Posted 26 Sep 2011 Link to this post

    Hi Simon,

    You should add the item before binding the RadMultiColumnComboBox to your data source. You can do it by using the following code snippet:

    Dim table As DataTable = Me.GetDataSource()
    Dim row As DataRow = table.NewRow()
    row("ID") = -1
    row("CompanyName") = "All"
    table.Rows.InsertAt(row, 0)
    Me.radMultiColumnComboBox1.DisplayMember = "CompanyName"
    Me.radMultiColumnComboBox1.ValueMember = "ID"
    Me.radMultiColumnComboBox1.DataSource = table

    You can not clear rows directly by using the Clear method of the rows collection when the controls is in bound mode. Nevertheless, you can iterate through the rows and delete each of them:
    Dim rows As New List(Of GridViewRowInfo)(Me.radMultiColumnComboBox1.EditorControl.Rows)
    For Each rowInfo As GridViewRowInfo In rows

    I hope this helps.

    All the best,
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top