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
  • Cheers. Thats exactly what I was looking for.

    Can you confirm that the following TWO lines of code do what I THINK they should do...

    1) To set the selection bar on a listbox value I use...

    invoke BankList::SetSelected(indexOfSelection, True)

    ..where BankList is my Listbox name and 'indexOfSelection' has been defined in local storage as binary long value 0.

    & 2) to retrieve the data within my listbox where the user has selected a value from the list is...

    set BankDetails to BankList::GetSelected(indexOfSelection)

    ..where BankDetails is an 01 level containing subitems which appear as part of my listbox 'line' values

Reply
  • Cheers. Thats exactly what I was looking for.

    Can you confirm that the following TWO lines of code do what I THINK they should do...

    1) To set the selection bar on a listbox value I use...

    invoke BankList::SetSelected(indexOfSelection, True)

    ..where BankList is my Listbox name and 'indexOfSelection' has been defined in local storage as binary long value 0.

    & 2) to retrieve the data within my listbox where the user has selected a value from the list is...

    set BankDetails to BankList::GetSelected(indexOfSelection)

    ..where BankDetails is an 01 level containing subitems which appear as part of my listbox 'line' values

Children
No Data