Highlighted
Super Contributor.
Super Contributor.
2014 views

ComboBox

Jump to solution

Hello, I have a problem I need to fill a ComboBox in various programs, I was thinking about making a routine which would read the file and fills the ComboBox of the program that called this routine is to do this, thank you

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

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.

View solution in original post

0 Likes
6 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

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.

View solution in original post

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Thank you, Chris and sorry for the delay in responding, my hard drive crashed

0 Likes
Highlighted
Super Contributor.
Super Contributor.

Good morning, after the full combobox how can I take a process complete message ?, thank you

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

I am not quite sure what you are asking for here. Can you please clarify with more detail?

Thanks

0 Likes
Highlighted
Super Contributor.
Super Contributor.

In this routine you passed me I need to be given a message.

For example invoque type  MessageBox :: Show ("process completed ...").

0 Likes
Highlighted
Super Contributor.
Super Contributor.

      Sorry that I changed the routine and was

          class-id EncheCombos.Class1.

      working-storage section.

      77  fs pic x(002).

      01  Lnk-Parametros.

          03  Lnk-Fim             pic 9(001).

          03  Lnk-CodCliente      pic 9(005).

          03  Lnk-NomeCliente     pic x(050).

      method-id InstanceMethod.

      local-storage section.

      procedure division.

          declare fl as type bindcombo.fillList = new bindcombo.fillList

          goback.

      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(80).

      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

          invoke type MessageBox::Show("Processo Concluído")

          goback.

      end method.

      end class.

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.