Charles
Charles

Reputation: 548

Combobox in winform and many entries

I'm trying to get a combobox in winform that has around 5'000 entries. I've run into a problem before - addrange hangs with this many entries. I created a seperate control to do this for myself without lagging, but I'm adding this functionality to existing comboboxes.

I was looking up VirtualizingStackPanel for WPF when trying to see if I could get around this.

Is there a way to improve the performance of addrange for a couple of thousand string entries?

Upvotes: 0

Views: 816

Answers (1)

Dai
Dai

Reputation: 155055

Have you tried using ComboBox.BeginUpdate and ComboxBox.EndUpdate? Using those methods improves performance when adding items.

Of course, if you have 5000 items then maybe using a ComboBox isn't the right control (having more than 200 items or so makes scrolling impossible, which defeats the point of having a drop-down selector). Have you considered using a normal textbox but with an autocomplete provider instead?

Upvotes: 4

Related Questions