Adding DataSource to Ribbon Combo Box

3 posts, 1 answers
  1. Brendan
    Brendan avatar
    2 posts
    Member since:
    Feb 2008

    Posted 27 Feb 2008 Link to this post

    Hi

    I am having difficulty binding a RibbonBar ComboBox to a DataTable. I have created the RibbonBar control at Design-Time but all other objects are created at Run-Time for various application reasons.

    I am able to create a ribbonbar, tab, chunk and combobox objects. The radComboBoxElement does not display in my chunk unless i set the autosize property to False and manually set the size property. I set the datasource, displaymember and valuememeber properties to valid entries as I would a normal combobox, but at runtime the combobox does not populate.

    I have recreated the problem in a sample project below. I would appreciate any assistance anyone is able to offer. I have searched the forums but cannot find any articles specific to this issue.

    Regards

    Brendan
    Imports Telerik.WinControls  
    Imports Telerik.WinControls.UI  
     
    Public Class Form1  
     
    Friend tab1 As New TabItem  
        Friend commandtab1 As New RadRibbonBarCommandTab  
        Friend chunk1 As New RadRibbonBarChunk  
        Friend combo1 As New RadComboBoxElement  
     
     
        Private Sub Form1_Load(ByVal sender As System.ObjectByVal e As System.EventArgs) Handles MyBase.Load  
     
            Dim conSQLConnection As New SqlClient.SqlConnection("DATA SOURCE=SQLSERVER.DOMAIN.COM;Integrated Security=SSPI;INITIAL CATALOG=Table1")  
            Dim adpTable1Adapter As New SqlClient.SqlDataAdapter("SELECT * FROM Table1", conSQLConnection)  
            Dim tblTable1 As New DataTable  
     
            conSQLConnection.Open()  
            adpExpressAdapter.Fill(tblExpressComputers)  
     
     
            tab1.Text = "Tab 1" 
            commandtab1.Tab = tab1  
            ribbon1.CommandTabs.Add(commandtab1)  
     
            chunk1.Text = "Chunk 1" 
            commandtab1.Items.Add(chunk1)  
     
            combo1.AutoSize = False 
            combo1.Size = New Drawing.Size(100, 20)  
            combo1.DataSource = tblTable1Computers  
            combo1.ValueMember = "computer_id" 
            combo1.DisplayMember = "name" 
            chunk1.Items.Add(combo1)  
     
     
     
        End Sub 



  2. Answer
    Georgi
    Admin
    Georgi avatar
    212 posts

    Posted 28 Feb 2008 Link to this post

    Hi Brendan,

    I reviewed carefully your code and I noticed that you are adding the combobox after binding to the data table. Because RadComboBoxElement is not a control, it could not be bound do a data source before it is added in the control's hierarchy. So the possible solution is to your code like this: 

            chunk1.Items.Add(combo1)   
            combo1.DataSource = tblTable1Computers     
            combo1.ValueMember = "computer_id"    
            combo1.DisplayMember = "name"    
     

    I hope this helps.nIf you have any other questions, please do not hesitate to write us.

     
    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Brendan
    Brendan avatar
    2 posts
    Member since:
    Feb 2008

    Posted 28 Feb 2008 Link to this post

    Many Thanks for your swift assistance, this has resolved the issue.

    Kind Regards
Back to Top