Page 1 of 1

wxListCtrl, how to simply hide items for filtering

Posted: Tue Jun 21, 2011 1:08 pm
by spectrum
hi all,

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

regards,
angelo

Posted: Tue Jun 21, 2011 2:21 pm
by Auria
I'm sorry, I don't really understand.

Take a look at wxWindow::Hide and wxWindow::Show

Posted: Tue Jun 21, 2011 2:27 pm
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).

Re: wxListCtrl, how to simply hide items for filtering

Posted: Wed Jun 22, 2011 9:31 am
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

Re: wxListCtrl, how to simply hide items for filtering

Posted: Wed Jun 22, 2011 9:56 am
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.

Re: wxListCtrl, how to simply hide items for filtering

Posted: Wed Jun 22, 2011 12:30 pm
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

Re: wxListCtrl, how to simply hide items for filtering

Posted: Thu Jun 23, 2011 6:05 pm
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