Quantcast
Channel: Visual COBOL - Forum - Recent Threads
Viewing all articles
Browse latest Browse all 4356

RE: ComboBox

$
0
0

I have attached an example which invokes a method in a class that will create a List object containing the records of a data file and then return that list to the form so that it can be used in binding to a combobox control.

The source is as follows:

       class-id bindcombo.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           declare fl as type bindcombo.fillList = new bindcombo.fillList
           set bindingSource1::DataSource to fl::getList
           set comboBox1::DataSource to bindingSource1::DataSource
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke self::Close
           
       end method.
       
       method-id comboBox1_SelectionChangeCommitted final private.
       procedure division using by value sender as object e as type System.EventArgs.
           invoke type MessageBox::Show("Selection is " & comboBox1::SelectedItem)
       end method.
      
       end class.

       class-id bindcombo.fillList.
           select item-file assign to "itemfile.txt"
                            organization is line sequential
                            file status is file-status.
       file section.
       fd item-file.
       01 item-record  pic x(10).
       
       working-storage section.
       01 file-status  pic x(2) value spaces.
       method-id getList.
       local-storage section.
       procedure division returning mylist as list[string].
       
           open input item-file
           create mylist
       
           perform until exit
              read item-file
                 at end
                    exit perform
                 not at end
                    write mylist from item-record
              end-read
           end-perform
           close item-file
           goback.
           
       end method.
       end class.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>