Dynamically add RadComboBox to a form

7 posts, 0 answers
  1. carisch
    carisch avatar
    7 posts
    Member since:
    Jul 2007

    Posted 13 Mar 2008 Link to this post

    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);

  2. carisch
    carisch avatar
    7 posts
    Member since:
    Jul 2007

    Posted 13 Mar 2008 Link to this post

    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.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 14 Mar 2008 Link to this post

    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
  5. Carisch
    Carisch avatar
    25 posts
    Member since:
    Aug 2007

    Posted 15 Mar 2008 Link to this post

    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.
  6. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 18 Mar 2008 Link to this post

    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
  7. fruzicka
    fruzicka avatar
    27 posts
    Member since:
    Oct 2012

    Posted 05 Jun 2008 Link to this post

    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; 

  8. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 06 Jun 2008 Link to this post

    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready