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

RE: listBox (sample C#)

$
0
0

Hi Claudio,

Please see the documentation for the Listbox class here as it lists all of the methods, properties and events that are available to you.

If this is a single selection Listbox then the following will return the selected index and display it in a textbox.

       class-id testlistselect.Form1 is partial
                 inherits type System.Windows.Forms.Form.
       
       working-storage section.
       
       method-id NEW.
       procedure division.
           invoke self::InitializeComponent
           goback.
       end method.

       method-id button1_Click final private.
       procedure division using by value sender as object e as type System.EventArgs.
            invoke listBox1::"Items"::"Add"("Item 1")
            invoke listBox1::"Items"::"Add"("Item 2")
            invoke listBox1::"Items"::"Add"("Item 3")
            invoke listBox1::"Items"::"Add"("Item 4")
       end method.

       method-id listBox1_SelectedIndexChanged final private.
       procedure division using by value sender as object e as type System.EventArgs.
       
           declare selIndex as binary-long = listBox1::SelectedIndex
           set textBox1::Text to selIndex::ToString
       
       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>