populate a ComboBox

2 posts, 0 answers
  1. R
    R avatar
    8 posts
    Member since:
    Apr 2008

    Posted 09 Jul 2008 Link to this post

    I am trying to populate a ComboBox with data from a access db. I have the following code that works in a normal combobox, but with the radcombobox does nothing:

                    Dim ComboBox1 As New Telerik.WinControls.UI.RadComboBox 
     
                    Dim cn As OleDbConnection 
                    Dim connString As String = ligacao 
                    cn = New OleDbConnection(connString) 
     
                    cn.Open() 
                    Dim da As New OleDb.OleDbDataAdapter(sql, cn) 
     
                    Dim ds As DataSet = New DataSet 
                    da.Fill(ds, "Tabela"
     
                    With ComboBox1 
                        .DataSource = ds.Tables(0) 
                        .DisplayMember = "D1" 
                        .ValueMember = "D2" 
                    End With 

    Can you tell me what I have to change to make it work?

    Thanks
  2. Martin Vasilev
    Admin
    Martin Vasilev avatar
    1061 posts

    Posted 11 Jul 2008 Link to this post

    Hello R,

    Thank you for the question.

    Please keep the following in mind when creating and binding RadComboBox in run-time:
    1. Add your instance of RadComboBox to its parent form before data-binding occurs.
    2. Set its ValueMember and DisplayMember properties before setting its DataSource. This will significantly increase the performance.
    I hope this is helpful. If you have other questions do not hesitate to contact me again.

     
    All the best,
    Martin Vasilev
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top