This is a migrated thread and some comments may be shown as answers.

adding an item and clearing all items

1 Answer 194 Views
MultiColumn ComboBox
This is a migrated thread and some comments may be shown as answers.
Simon
Top achievements
Rank 1
Simon asked on 21 Sep 2011, 12:16 PM
Private Sub LoadSupplierCombo()
        Cursor = Cursors.WaitCursor
        tsstatus.Text = "Loading Suppliers, please wait..."
        Refresh()
        '     cbSuppliers..MasterTemplate.AutoGenerateColumns = True
 
        Dim TicketsDA As SqlDataAdapter
        Dim TicketsDS As DataSet
        Dim TicketsDV As DataView
        Dim SQLString As String = ""
 
 
        DBOpen()
        Try
 
            SQLString = "SELECT     Supplier.SupplierName AS Supplier, Supplier.SupplierAccountNo AS [Account No] " & _
"FROM         SZTickets INNER JOIN " & _
                     " SZTicketStatus ON SZTickets.statusId = SZTicketStatus.id INNER JOIN " & _
                     " SZTicketPriority ON SZTickets.priorityId = SZTicketPriority.id 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
 
            SQLcmd.Dispose()
            TicketsDA.Dispose()
 
 
 
 
        Catch ex As Exception
            g_error.DBErrorMsg("Failure to load tickets", SQLString, ex)
        Finally
            dgTickets.ResumeLayout()
            DBClose()
        End Try
        Cursor = Cursors.Default
        tsstatus.Text = ""
 
        Dim columns As RadMultiColumnComboBoxElement = cbSuppliers.MultiColumnComboBoxElement
 
        For Each column As GridViewDataColumn In columns.Columns
            column.BestFit()
        Next
 
        
    End Sub


Hi

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?

Cheers

Baz

1 Answer, 1 is accepted

Sort by
0
Svett
Telerik team
answered on 26 Sep 2011, 11:32 AM
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
    rowInfo.Delete()
Next

I hope this helps.

All the best,
Svett
the Telerik team

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

Tags
MultiColumn ComboBox
Asked by
Simon
Top achievements
Rank 1
Answers by
Svett
Telerik team
Share this question
or