Filtering a wxListBox?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dparks
Knows some wx things
Knows some wx things
Posts: 28
Joined: Sat Feb 03, 2007 7:51 am

Filtering a wxListBox?

Post by dparks » Fri Jun 27, 2008 8:39 pm

Hello,

I wish to fill a wxListBox with a number of strings (approx. 100K) and than allow the user to enter text in a wxTextCtrl in order to filter the items in the listbox. Specifically, I want the listbox to only display strings that starts with the string entered in the textbox.

It would be great if there was a wxWidget that did this, but I am guessing this is not the case. As such, can anyone recommend a good method to do this sort of filtering on a vector/array of strings. This is a very common feature of many programs. What is the "standard" way to do this?

Much thanks.

Donovan

NinjaNL
Moderator
Moderator
Posts: 899
Joined: Sun Oct 03, 2004 10:33 am
Location: Oosterwolde, Netherlands

Post by NinjaNL » Mon Jun 30, 2008 9:50 am

I'd be interested in whether anyone else has done this.

I would suggest checking the contents of the text control, performing the filtering yourself, and then Clearing the listbox and then filling it again with the filtered contents.

You might be able to look at other autocomplete controls to examine their methodology, and see if you can apply it to your own programs.

You might also implement your own component, subclassing the current wxListBox, and adding filtering properties/functions to it.
Follow the development of my screenplay authoring program at http://wxscreenplaywriter.blogspot.com/

Post Reply