locked
listview help RRS feed

  • Question

  • Hi,

    in my winform, i'm trying to group items in listview and i want to display the items vertically.

    i found an example that just adds items and groups:

     for (int groupIndex = 0; groupIndex < 3; ++groupIndex)
                {
                    this.listView1.Groups.Add("GroupKey" + groupIndex, "Test" + groupIndex);
    
                    for (int index = 0; index < 5; ++index)
                    {
                        ListViewItem item = new ListViewItem("Test " + groupIndex + "/" + index,
                                                             this.listView1.Groups[groupIndex]);
                        this.listView1.Items.Insert(0, item);
                        this.listView1.Groups[groupIndex].Items.Insert(0, item);
                    }
                }
    
                for (int groupIndex = 2; groupIndex >= 0; --groupIndex)
                {
                    for (int index = 0; index < 5; ++index)
                    {
                        ListViewItem item = new ListViewItem("Test2 " + groupIndex + "/" + index,
                                                             this.listView1.Groups[groupIndex]);
                        this.listView1.Items.Insert(0, item);
                        this.listView1.Groups[groupIndex].Items.Insert(0, item);
                    }
                }

    i can't make the items to be displayed vertically and i want to have the option to collapse the groups.

    how can it be done?

    Thanks,

    Gidi.

    Sunday, March 18, 2012 2:17 PM

Answers

  • found the answer: listView1.View = View.Details;
    • Marked as answer by gidi Sunday, March 18, 2012 2:34 PM
    Sunday, March 18, 2012 2:34 PM

All replies

  • found the answer: listView1.View = View.Details;
    • Marked as answer by gidi Sunday, March 18, 2012 2:34 PM
    Sunday, March 18, 2012 2:34 PM
  • I'm glad to hear that the question is solved.

    Best wishes,


    Mike Zhang[MSFT]
    MSDN Community Support | Feedback to us

    Monday, March 19, 2012 2:14 AM