wxListCtrl, how to simply hide items for filtering

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
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

wxListCtrl, how to simply hide items for filtering

Post by spectrum »

hi all,

is there a way to hide an item, to re-show it removing a specific filter ?

regards,
angelo
spectrum
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

I'm sorry, I don't really understand.

Take a look at wxWindow::Hide and wxWindow::Show
"Keyboard not detected. Press F1 to continue"
-- Windows
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Post by briceandre »

I don't think there is a dedicated way to hide a given element of a wxListCtrl.

What you can do is handle yourself the elemetns that will be displayed. In this case, you can use the wxListCtrl in wxLC_VIRTUAL mode. So, to hide an element, you simply reconfigure the number of elements that are contained (wxListCtrl::SetItemCount) and you refresh all items located after the first element removed (wxListCtrl::RefreshItems).
spectrum
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Sat Jul 21, 2007 12:17 pm

Re: wxListCtrl, how to simply hide items for filtering

Post by spectrum »

hi all,

many thanks, maybe is better i explain better what i am trying to do, so maybe you can give me the best way to reach this:

I receive some messages (UDP) from the network, and append them to a 4 colum wxListCtrl (time,IP,level,message).

I need to add a feature to filter for IP, that when is applied, shows only the filtered IP's, including the messages already added before.
Also, i need of course to remove the filter and show all back.

Is possible wxListCtrl is not appropriate ?

Any suggestion for a good method is really appreciated.
many thanks
angelo
spectrum
briceandre
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 672
Joined: Tue Aug 31, 2010 6:22 am
Location: Belgium

Re: wxListCtrl, how to simply hide items for filtering

Post by briceandre »

For me wxListCtrl is appropriate for this purpose, but you will have to implement filtering yourself. You can perform that with the method I described in previous post.
ngpaton
Knows some wx things
Knows some wx things
Posts: 25
Joined: Tue May 20, 2008 8:23 am

Re: wxListCtrl, how to simply hide items for filtering

Post by ngpaton »

Hi Angelo,

One possibility if using wx2.9 is to use a wxGrid as this has ShowRow/HideRow methods.

Note that I've not tried this before myself.

Cheers

Nigel
sjnc.puzzle
Earned a small fee
Earned a small fee
Posts: 13
Joined: Wed Jun 22, 2011 6:01 pm

Re: wxListCtrl, how to simply hide items for filtering

Post by sjnc.puzzle »

I did this myself.
I added a wxSearchCtrl entry area. Then when the event for the wxSearchCtrl occurrs, I DeleteAllItems() in the wxListCtrl. And go back thru and only add items that return true for listString.Matches(filterString).

My default filterString is "*"

If you need you can get more complicated than the simple wxString::Matches() method.

-- Scott
Post Reply