Link to home
Start Free TrialLog in
Avatar of NewMom2Brandon
NewMom2Brandon

asked on

URGENT Need help with ListView Tag item

I have a tag assigned to each item added into a listview.

It looks like this
item.Tag = sCat + ", " + sDog + ", " + sBreed + ", " + sPetName + ", " + sPetAge;

What I need to pull the first item from the listview and populate 5 text boxes with the information in the tag. For example Cat would go in 1 box, dog in another and so on.

Then if the listview selected item changes...I would need to update the fields with the new tag information.

The reason I used Tags was becasue I couldn't think of another way to have the information hidden from the main screen. So I just used the tag for each line.

Does anyone have any code examples on how I could do this. Or a better way of doing this.
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

I would get rid of the space after your comma...then use code like this:

            item.Tag = sCat + "," + sDog + "," + sBreed + "," + sPetName + "," + sPetAge;

            String[] values = item.Tag.ToString().Split(",".ToCharArray());
            for (int i = 0; i <= values.GetUpperBound(0); i++)
            {
                Debug.WriteLine(values[i]);
            }
ASKER CERTIFIED SOLUTION
Avatar of gemailj
gemailj
Flag of Egypt image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
plz inform me about ur opion

thanks for grade A
Avatar of NewMom2Brandon
NewMom2Brandon

ASKER

I think it is a very professional solution. Concidering I need to access these values in mulitiple places making it public is a better than using the same function in mulitple places.

This was the way I would have gone if several other factors had not needed to change in my project. Instead I went the direction of creating a hashtable and using that to filter out the view instead of using the tags.