Created On:  03 July 2012


A ListView control has been defined in a Windows Forms application under Visual COBOL.

The ListView has multiple columns defined.

When using the Add method of the Items property the first column can be populated with data as follows:

      invoke listView1::Items::Add(myString)

How can each individual column be populated with a data field separately?


There are several ways to do this, including binding to a list or other object but the following is a real simple method.

You need to create a ListViewItem and then add the subitems to it.  The first item is the first column and each subitem is the next column etc.

method-id button1_Click final private.
01 row type ListViewItem.
procedure division using by value sender as object e as type System.EventArgs.

    set row to new ListViewItem("Column1 Data")
    invoke row::SubItems::Add("Column2 Data")
    invoke row::SubItems::Add("Column3 Data")
    invoke listView1::Items::Add(row)