Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1290
Traversing a WinListView
posted

Hi,

I'm currently adding items with multiple columns into a WinListView as follows:

            UltraListViewSubItem item2 = new UltraListViewSubItem();

            item2.Value = text;            

            UltraListViewSubItem[] itemArray = new UltraListViewSubItem[] { item2 };

            UltraListViewItem item = new UltraListViewItem(field, itemArray);            

            listContainer.Items.Add(item);

How do I write the loop such that I can get the value/text of the sub items as well? As of now, I can only get the text of the 1st column.

  • 69832
    Offline posted

    private void Foo( UltraListView listView )

    {

        foreach( UltraListViewItem item in listView.Items )

        {

            object itemValue = item.Value;

     

            foreach( UltraListViewSubItemColumn column

    in listView.SubItemColumns )

            {

                object subItemValue = item.SubItems[column];

            }

        }

    }