locked
Flickering ComboBox when loading data from Database RRS feed

  • Question

  • I have a combobox that gets new set of data (bounded to DataTable) everytime user select a data from another combobox.

     

    The combobox always dissappear then reappear, how do I prevent that?

    I tried to suspend layout and resume layout and it still the same. I tried to make the container doublebuffered but still does not make any difference.

     

    Is multi-threading going to help?

    I have no idea how to do mutlti-threading though, I don't like ms online documentation either, Java API is so much nicer but anyway, I need solution to the flickering problem!!

     

    Thanks,

    Max

     

    Friday, July 27, 2007 1:41 AM

Answers

  •  

    I add data through the use of the DataTable not through the ComboBox.

     

    Code Snippet

    DataTable data = (DataTable)myCombo.DataSource;

    data.BeginUpdate();

    //do all database operation here.

    data.EndUpdate();

     

     

    Anyway I just found a solution to this, but not a very good one.

    I basically use 2 DataTable and then just swap them! similar to how doublebuffering works.

    This uses a lot more memory but my combobox no longer flicker!

     

    Regards,

    Max

    Friday, July 27, 2007 3:00 AM

All replies

  • Dear o0..

     

    Before adding items to the combo, add the BeginUpdate(), fill the combo and then the EndUpdate() method.

     

    Eg:

     

    cmb.BeginUpdate();
     for (int x = 0; x < 100;x++)

     {
            cmb.Items.Add("item" + x.ToString());
     }
    cmb.EndUpdate();

     

    HTH,

    Suprotim Agarwal

     

    Friday, July 27, 2007 2:44 AM
  •  

    I add data through the use of the DataTable not through the ComboBox.

     

    Code Snippet

    DataTable data = (DataTable)myCombo.DataSource;

    data.BeginUpdate();

    //do all database operation here.

    data.EndUpdate();

     

     

    Anyway I just found a solution to this, but not a very good one.

    I basically use 2 DataTable and then just swap them! similar to how doublebuffering works.

    This uses a lot more memory but my combobox no longer flicker!

     

    Regards,

    Max

    Friday, July 27, 2007 3:00 AM