performance issue when loading images in to the combo box.

2 posts, 0 answers
  1. Ragupathi
    Ragupathi avatar
    41 posts
    Member since:
    Jul 2008

    Posted 18 Dec 2008 Link to this post

    Hi
    I am adding gif files in to my Radcombobox items. But while adding the images, combobox is taking time to load those images.


    Please find the following code which I used to populate the images.

    RadComboBoxItem item;                   
                             for (int i = 0; i < dtTables.Rows.Count; i++)
                            {
                                item = new RadComboBoxItem();
                                if (dtTables.Rows[i][1].ToString() == "Table")
                                {
                                    item.Image = Image.FromFile(imagepath1);
                                    item.TextImageRelation = TextImageRelation.ImageBeforeText;
                                }
                                else
                                {
                                    item.Image = Image.FromFileimagepath2);
                                    item.TextImageRelation = TextImageRelation.ImageBeforeText;
                                }
                                item.Text = dtTables.Rows[i][0].ToString();
                                cbx.Items.Add(item);
                            }

    RowCount  will be around 450. If I remove the images then loading data in to the combo box is fast.

    Can you please let me know any thing I can do for improving the performance. ?

    Thanks in Advance.
    Raghu
  2. Nikolay
    Admin
    Nikolay avatar
    1803 posts

    Posted 20 Dec 2008 Link to this post

    Hello Ragupathi,

    Thank you for the question.

    In order to optimize the performance, you should read the images from the files in advance and put them into an ImageList. Then, when you start creating and adding RadComboBoxItems, use this ImageList to get the necessary images. I am attaching a sample project that demonstrates this approach.

    You can get another performance optimization by using BeginUpdate/EndUpdate. You can find an example of calling these methods in our Quick State Framework examples, section Editors >> RadComboBox >> Loading items.

    I hope this helps. If you have additional questions, feel free to contact me.

    All the best,
    Nikolay
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top