J
Johnny J.
I would like to implement a filter function on a ListView control, and I
found this code on TheCodeProject:
http://www.codeproject.com/cs/miscctrl/listviewfilter.asp
Since it's not possible to toggle the ListViewItem's visibility, the
filtering is acheived (in this case) by moving the "non-matching" item to a
temporary collection and returning them to the ListViewItem collection when
they are no longer filtered out.
That approach works ok in this case, because the listviewitems are sorted,
but if they are not, the CodeProject code will not work, because items that
are reinserted in the ListViewItem collection are merely added and will thus
appear at the bottom of the list.
Is there any way of easily keeping track of the original order and
reinserting the items in their original position?
Cheers,
Johnny J.
found this code on TheCodeProject:
http://www.codeproject.com/cs/miscctrl/listviewfilter.asp
Since it's not possible to toggle the ListViewItem's visibility, the
filtering is acheived (in this case) by moving the "non-matching" item to a
temporary collection and returning them to the ListViewItem collection when
they are no longer filtered out.
That approach works ok in this case, because the listviewitems are sorted,
but if they are not, the CodeProject code will not work, because items that
are reinserted in the ListViewItem collection are merely added and will thus
appear at the bottom of the list.
Is there any way of easily keeping track of the original order and
reinserting the items in their original position?
Cheers,
Johnny J.