Hi,
I have used an ultracomboeditor to populate on the dropdown click, this is done asynchronously and when completed binds the combo's datasource and I call control.Invalidate to refresh the list, although this does not work, you have to click on the drop down twice, it works for the plain .net winforms combobox so why dosent it work for the ultracomboeditor??, I have tried everything and its really frustrating as i have used this control everywhere in my application and this is a vital change i need to do for performance.
UltraComboEditor and the inbox ComboBox control are two completely different controls with totally different implementations. So you really can't expect something like what you are doing here to work for both.
I'm not sure exactly what you are trying to do or how you are trying to do it - there's not much information here to go on, so I don't know why it's not working.
What event are you handling?
What, exactly, are you doing asynchronously?
control.Invalidate probably doesn't do anything to the list portion of UltraComboEditor, it most likely only applies to the edit portion.
If you can post a small sample project of what you are trying to do, I could take a look and see if I can tell you why it doesn't work.
I have attached an example solution.
Since you are getting the data Asynchronously, the Combo is determining the size of the dropdown before there is any data or even a data source attached. So it's dropping down, but it's very small.
The second time you drop it down, it has a DataSource and the data is already there, so it can determine the proper size.
Comparing to the MS Combo isn't really a fair test here, since the UltraComboEditor's dropdown size calculation is much more complicated in order to support all the features that the UltraComboEditor has and the MS Combo doesn't. There's no way to force the ultraComboEditor to resize it's list while it is already dropped down.
But I found a couple of potential workarounds for you.
1) Fill the ultraComboEditor with a few dummy items before it is ever dropped down.
public Form1() { InitializeComponent(); for (int i = 0; i < 8; i++) { this.ultraComboEditor1.Items.Add(0, string.Empty); } }
2) Trap for the first time the combo is dropped down and close it up and then drop it down again.
bool firstDropDown = true; private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { DataTable dt = e.Result as DataTable; ultraComboEditor1.DataSource = dt; ultraComboEditor1.ValueMember = "Value"; ultraComboEditor1.DisplayMember = "Text"; if (this.firstDropDown) { this.firstDropDown = false; this.ultraComboEditor1.CloseUp(); this.ultraComboEditor1.DropDown(); } }
Personally, I like the first one, since with the second one, you get a little bit of a flicker the first time you drop it down.
Hi Mike,
Your first workaround is great and am using it, thanks for your help!