Combobox Usage VS2003 -> VS2005

I need to populate a C# Combobox with potentially several thousand items. I know this is not recommended but this is after horiz data splitting so it's the best I can do. In VS2003, I tried binding to a dataset but this was way too slow so I started loading the Itemlist from a datareader and it worked great. No more than 2 seconds to load several thousand items and memory usage stayed well within reasonable limits. I tried the same code compiled under VS2005 hoping to use Autocomplete and it worked well for very small lists but was many times slower for the normal lists I use. Several minutes compared to a couple of seconds. Additionally, the memory usage steadily climbed during loading to several times what was required under VS2003.

I'm going to try using a dataset again to see if that improves performance but I'm really looking for advice on how best to handle large lists (1,000<#<10,000) in a Combobox in WinForms. BTW, the Autocomplete works fine.

Thanx,
GarthK

[996 byte] By [GarthK] at [2008-2-20]
# 1
BTW, running the Perf Analyzer showed that ObjectCollection.Add used up over 97% of the cpu time. I guess this comes as no surprize given what I'm doing but the overall performance (or lack thereof) came as a surprize to me.

Thanx,
GarthK

GarthK at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 2

You are correct - there are issues related to ComboBox performance with AutoComplete enabled and we are investigating those issue. In Beta 2, you can get a significant performance increase by enabling AutoComplete after the ComboBox has been loaded.

Joe

JoeStegman at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 3
The phrase "significant performance increase" is an understatement! Smile Turning off Autocomplete before loading the list and back on after makes the performance very nearly that of VS2003.

Is my approach to using Combobox lists still a reasonable one or should I be looking at binding to a dataset again?

Thanx,
Garth

GarthK at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 4
If you set DisplayMember and ValueMember prior to binding, data binding performance should be on par with manually populating the items collection. If you see something different, let me know and we'll look into it.

Thanks,

Joe

JoeStegman at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 5
Could you expand on "... enabling AutoComplete after the ComboBox has been loaded."? Perhaps a simple example of the events that should be used to achieve this suggested implementation would help clarify.
JustJoe at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...
# 6

Sure. You can use the designer to fill the ComboBox (for example via data binding) and then write code in the Form.Load event to enable AutoComplete:


this.comboBox3.AutoCompleteSource = AutoCompleteSource.ListItems;
this.comboBox3.AutoCompleteMode = AutoCompleteMode.Append;

Or, if you're manually populating the ComboBox in code, you will need to do the following:


FillComboBox(this.comboBox3)
this.comboBox3.AutoCompleteSource = AutoCompleteSource.ListItems;
this.comboBox3.AutoCompleteMode = AutoCompleteMode.Append;

Post Beta 2, you will be able to setup AutoComplete and data binding in the designer without this performance penalty.

Joe Stegman
The Windows Forms Team
Microsoft Corp.

This posting is provided "AS IS" with no warranties, and confers no rights.

JoeStegman at 2007-9-8 > top of Msdn Tech,Windows Forms,Windows Forms Data Controls and Databinding...