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

Adding DataSource to Ribbon Combo Box

2 Answers 87 Views
RibbonBar
This is a migrated thread and some comments may be shown as answers.
Brendan
Top achievements
Rank 1
Brendan asked on 27 Feb 2008, 08:11 AM
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 Answers, 1 is accepted

Sort by
0
Accepted
Georgi
Telerik team
answered on 28 Feb 2008, 05:27 PM
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
0
Brendan
Top achievements
Rank 1
answered on 28 Feb 2008, 10:45 PM
Many Thanks for your swift assistance, this has resolved the issue.

Kind Regards
Tags
RibbonBar
Asked by
Brendan
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Brendan
Top achievements
Rank 1
Share this question
or