C# - Printing out groupnames, items and subitems in a loop?

Posted by Nike on Stack Overflow See other posts from Stack Overflow or by Nike
Published on 2010-04-20T19:06:46Z Indexed on 2010/04/20 19:13 UTC
Read the original article Hit count: 177

Filed under:
|
|

What I'm trying to do, is to store all groupnames, items and subitems from a listview into a string. Take a look at the following screenshot.

http://i.imagehost.org/0355/5_35.png

I'm kind of stuck though, with the loop. I'm pretty sure i can figure out how to actually store it in a variable though.

The following code will loop through all of the listview Items:

int countGroups = csslistview.Items.Count;
foreach (ListViewItem lvi in csslistview.Items){
    //code here
    countGroups++;
}

But i can't figure out how to loop through all of the Groups. I tried this, but it's not working:

int countGroups = csslistview.Groups.Count;
foreach (ListViewItem lvi in csslistview.Items){
    //code here
    countGroups++;
}

I'm trying to echo it out as CSS, if you're wondering. The grouname is the id/class/tag, the item is the rule, and the subitem is the property.

So, any ideas?

© Stack Overflow or respective owner

Related posts about c#

Related posts about listview