Adding column data to a list view control in Visual COBOL

I started using a simple listbox but the data was never formatted correctly.  So I tried the List View control and this looks better.  I need two columns to hold the data.  Here is my code:

method-id PopulateListbox final private.

local-storage section.

01 SiteList.

   05 SiteListDesc  pic x(40) value spaces.

   05 Filler        pic x(2)  value spaces.

   05 SiteListNum   pic x(4)  value spaces.

procedure division.

    if ds-return = spaces

       invoke lbxSites::BeginUpdate

       invoke listView1::BeginUpdate

       perform varying idx from 1 by 1 until idx > 99

           if lb-siteentry(idx) > spaces

               move LB-SITEENTRY-DESC(idx) to SiteListDesc

               move LB-SITEENTRY-NUM(idx) to SiteListNum

               invoke lbxSites::Items::Add(SiteList)

               invoke listView1::Items::Add(SiteListDesc)

               *>invoke listView1::SubItems::Add(SiteListNum)

           else

               exit perform    

           end-if

       end-perform   

       invoke lbxSites::EndUpdate

       invoke listView1::EndUpdate

    end-if

end method.

In one of the Sams Teach Yourself books, it suggests using Subitems.Add code I have commented out above.  The compiler doesn't like it.  Can someone tell me how to fill in the second thru NN columns in a listview?

My form is below:

 

  • Verified Answer

    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)