jplonguev_sbcglobal_ Absent Member.
Absent Member.
2317 views

Adding column data to a list view control in Visual COBOL

Jump to solution

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:

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Adding column data to a list view control in Visual COBOL

Jump to solution

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)

 

0 Likes
1 Reply
Highlighted
Micro Focus Expert
Micro Focus Expert

RE: Adding column data to a list view control in Visual COBOL

Jump to solution

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)

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.