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

Loading Combobox... Performance Issue..

1 Answer 141 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.
fgalarraga
Top achievements
Rank 1
fgalarraga asked on 24 Nov 2007, 09:33 AM
Hello..
I am trying to load RadCombobox by using the following code.
            
      foreach (SuperProgram superProgram in SuperPrograms)
               {
                   RadListBoxItem listitem = new RadListBoxItem();
                   listitem.Value = superProgram.ProgramMsg.MenuName;
                   listitem.Text = superProgram.ProgramMsg.MenuCaption;
                   LsvPgramAvail.Items.Add(listitem);
               }

It takes long time to load. Whereas in Microsoft's combobox the performance is very good.

Do I need any additional code??

Thanks...

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 27 Nov 2007, 02:32 PM
Hello fgalarraga,

Actually, you need some additional code. There are two ways to speed up the performance of RadComboBox:

  1. Call BeginUpdate at the beginning of the code block that fills RadComboBox with data and EndUpdate at the end of it: 
     
    LsvPgramAvail.BeginUpdate();             
                
    foreach (SuperProgram superProgram in SuperPrograms)              
    {              
        RadComboBoxItem comboitem = new RadComboBoxItem();              
        comboitem.Value = superProgram.ProgramMsg.MenuName;              
        comboitem.Text = superProgram.ProgramMsg.MenuCaption;              
        LsvPgramAvail.Items.Add(comboitem);              
    }           
           
    LsvPgramAvail.EndUpdate();     
     

  2. Set IntegralHeight to True to use RadComboBox data virtualization. Note, that this makes all items in the RadComboBox of equal height: 
    // Set the DropDown minumim size and the amount of items to be shown        
    this.LsvPgramAvail.DropDownMinSize = new Size(0, 20);        
    this.LsvPgramAvail.MaxDropDownItems = 8;        
           
    // Use the RadComboBox data vitualization        
    this.LsvPgramAvail.IntegralHeight = true;        
           
    foreach (SuperProgram superProgram in SuperPrograms)           
    {           
        RadComboBoxItem comboitem = new RadComboBoxItem();           
        comboitem.Value = superProgram.ProgramMsg.MenuName;           
        comboitem.Text = superProgram.ProgramMsg.MenuCaption;           
        LsvPgramAvail.Items.Add(comboitem);           
    }      
     

    In the current release of our controls there is an issue with the height of the dropdown window, which has already been fixed. Currently, to get a dropdown window with eight items (as shown in the snippet above) you should set the DropDownMinSize property to a value greater than the height of the first item (for example set it to (0, 20)), and then attach to the Shown event of the form and insert these two lines in the event handler: 

    private void Form1_Shown(object sender, EventArgs e)        
    {        
         LsvPgramAvail.ShowDropDown();        
         LsvPgramAvail.CloseDropDown();          

     

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

 

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
fgalarraga
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or