listview change color of text if text in column is..

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I have a listview and i have a combo box and a button.

In the listview I have a few columns and under column 3 i have the text either "Free" or "Members". So in the combo box i have the choices free or members

When the button is clicked, I would like it to hide or remove items that do not have what was selected in the combo box.
 
There is no easy way to do this...nothing for free in the control. You'll have to clear out the items in the listview and then repopulate it based on the filtered items.

No easy way around it. The same goes for highlighting columns and things of that nature. You have to go through the list view and do it by hand.
 
well i have tried to do:

If listview1.items.subitems.text = "Members" Then
listview1.items.remove()
End If

But for some reason you click the button and it removes some, then you have to click it another 4 times til it clears them all out.. any ideas why its doing this?
 
That is only going to remove the selected item. I would clear the list and then add only the things that meet the user's specific filter criteria.
 
don't i have to then save whats all in the listview to a file? or is there a code that knows whats in the listview when the program first starts up?
 
You don't have to save it to a file but you do need to save it to some capacity. Wether that be a Collection Object of some kind (such as an ArrayList or Array) or a DataBase or a file or whatever, is left completely up to you.

And besides, it is bad practice to use user interface controls to hold all of your data. they should only be displaying you data. The ideal program is one where you can exchange one user interface for another and lose none of the main, business functionality of your program. If you decided that you wanted to use a command line interface, for example, what would you do? It sounds like you'd be up a creek if everything resides in a listview. sometims (cringe) it's ok, but if you expect this program to have any kind of legs and be maintainable in the long term you should sperate your UI from your business logic.
 
so far the only control i really have used to store all the data in is this listview, all my other listview, listboxes, etc i have load the data from a file.
 
It sounds like with a little refactoring you'll be well on your way.

good luck and have fun..
 
Well I have tried a few things and I can't really get anything to work the way I want it to.. so isn't there some way to work around it by hiding or completely removing items that do not contain the certain text in a column?
 
Back
Top