Filling list boxes in .NET code

[Migrated content. Thread originally posted on 11 May 2012]

The following code doesn't seem to display my listbox contents after performing it. What am I missing?

method-id LBox_Button_Click final private.
local-storage section.
01 my-listbox type System.Windows.Forms.ListBox.
01 companyName type String.
procedure division using by value sender as object e as type System.EventArgs.

set my-listbox to new System.Windows.Forms.ListBox
invoke my-listbox::BeginUpdate

move "Fred" to companyName
invoke my-listbox::Items::Add(companyName)

invoke my-listbox::EndUpdate

end method.
Parents
  • Have defined the listbox as part of a form. Listbox is called 'CompanyList'.

    As part of my code 'behind the form' code reads as:

    method-id CompanyList_SelectedIndexChanged final private.
    local-storage section.
    01 companyName type String.
    procedure division using by value sender as object e as type System.EventArgs.

    invoke self::Controls::Add(CompanyList)
    invoke CompanyList::BeginUpdate

    move "Fred" to companyName
    invoke CompanyList::Items::Add(companyName)
    invoke CompanyList::EndUpdate

    end method.


    When running the form, from the beginning, this code does not appear to be executed and my 'list box' remains empty.

    What commands trigger this code to run so that on loading the screen the listbox is filled in?

    Thanks.
Reply
  • Have defined the listbox as part of a form. Listbox is called 'CompanyList'.

    As part of my code 'behind the form' code reads as:

    method-id CompanyList_SelectedIndexChanged final private.
    local-storage section.
    01 companyName type String.
    procedure division using by value sender as object e as type System.EventArgs.

    invoke self::Controls::Add(CompanyList)
    invoke CompanyList::BeginUpdate

    move "Fred" to companyName
    invoke CompanyList::Items::Add(companyName)
    invoke CompanyList::EndUpdate

    end method.


    When running the form, from the beginning, this code does not appear to be executed and my 'list box' remains empty.

    What commands trigger this code to run so that on loading the screen the listbox is filled in?

    Thanks.
Children
No Data