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

Dynamically add RadComboBox to a form

6 Answers 154 Views
ComboBox and ListBox (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
carisch
Top achievements
Rank 1
carisch asked on 13 Mar 2008, 02:32 PM
When I use the RadComboBox through the designer all works correctly.  I now want to add the RadComboBox dynamically through code.  When I bind this control to a datasource, it will not work for me.  Please help.

RadComboBox box = new RadComboBox();

box.DisplayMember =

"name";

box.ValueMember =

"portfolioId";

box.DataSource = p.DefaultView;

box.Top = 10;

box.Left = 10;

Controls.Add(box);

6 Answers, 1 is accepted

Sort by
0
carisch
Top achievements
Rank 1
answered on 13 Mar 2008, 02:36 PM
Submitted too soon, let me clarify. 
  • the control is on my form, but it is not styled like a designer created one.  It looks very bad.
  • it is not bound to anything, no drop down effects at all.
0
Nikolay
Telerik team
answered on 14 Mar 2008, 04:41 PM
Hello carisch,

If you want to dynamically create a RadComboBox and bind it, you should first add it to the form's controls collections and after that set its DataSource. As far as its style it concerned, a theme should be applied to the control.

Please refer to the code snippet below:
RadComboBox box = new RadComboBox();  
box.DisplayMember = "name";  
box.ValueMember = "portfolioId";  
box.ThemeName = "ControlDefault";  
box.Top = 10;  
box.Left = 10;  
this.Controls.Add(box);  
box.DataSource = p.DefaultView; 

If you have additional questions, do not hesitate to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Carisch
Top achievements
Rank 1
answered on 15 Mar 2008, 12:13 PM
Thanks that was it. 

Is this documented anywhere that I could have solved this issue on my own?  Can you point me to that documentation. 

To be honest, no controls I've worked with have ever needed to be added to the collection first, before binding.  I wasted a good several hours on this issue.

Thanks again,

Brian.
0
Nikolay
Telerik team
answered on 18 Mar 2008, 12:14 PM
Hi Brian,

Thank you for pointing the comparison out.

We will consider changing the behavior of RadComboBox for the Q1 2008 release, so you will be able to first bind it and then add it to the controls collection.

If you have additional questions, do not hesitate to contact me.

Greetings,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
fruzicka
Top achievements
Rank 1
answered on 05 Jun 2008, 11:29 AM

Sorry, this belongs to radGridView. Can please someone delete it from here.

Hi, im have troubles with this too. Using the latest release Q1 SP1 2008 my GridViewComboBoxColum (GridViewLookupColumn) doesn't show any values. here some snipet (this was working in Q3 2007):

GridViewLookUpColumn tcReason = new GridViewLookUpColumn();  
tcReason.UniqueName = "Reason";  
tcReason.FieldName = "IdReason";  
tcReason.HeaderText = "Reason";              
tcReason.DataSource = colReason  
tcReason.DisplayMember = "Name"//colReason  
tcReason.ValueMember = "Id"//colReason  
//...  
rgvStamps.Columns.Insert(rgvStamps.Columns.Count, tcReason);  
//...  
rgvStamps.Datasource = colStamps; 

0
Nikolay
Telerik team
answered on 06 Jun 2008, 01:52 PM
Hello fruzicka,

I was not able to reproduce the issue. Please open a support ticket and send me a sample application which demonstrates it. This will allow me to address any potential issue further.

I am looking forward to your response.

All the best,
Nikolay
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ComboBox and ListBox (obsolete as of Q2 2010)
Asked by
carisch
Top achievements
Rank 1
Answers by
carisch
Top achievements
Rank 1
Nikolay
Telerik team
Carisch
Top achievements
Rank 1
fruzicka
Top achievements
Rank 1
Share this question
or