ListBox

ListBoxは、リストボックスコントロールを扱うクラス・・・。

ListBox クラス (System.Windows.Forms)

Form1のロード時に、アイテムを3つ追加しておき、button1を押したら選択されているアイテムのテキストを表示するようにする・・・。

f:id:BG1:20160420112329p:plain

を選択し、

f:id:BG1:20160420112357p:plain

このように配置・・・。

f:id:BG1:20160420112457p:plain

Form1のLoadイベントをダブルクリックして、

listBox1.Itemsがアイテムのコレクション・・・。
listBox1.Items.Addでアイテムを追加・・・。
今回は、文字列"abc", "def", "ghi"を追加・・・。

f:id:BG1:20160420112753p:plain

button1も配置しておく・・・。
button1が押された時、

listBox1.SelectedItemに選択されたアイテムが格納されている・・・。
文字列をアイテムとして追加したので、object型からstring型にキャストして、それをMessageBoxで表示・・・。

f:id:BG1:20160420113054p:plain

"def"を選択して、button1を押すと、

f:id:BG1:20160420113121p:plain

"def"・・・。

f:id:BG1:20160420113136p:plain

"abc"を選択して、button1を押すと、

f:id:BG1:20160420113159p:plain

"abc"・・・。

f:id:BG1:20160420113212p:plain

"ghi"を選択して、button1を押すと、

f:id:BG1:20160420113235p:plain

"ghi"・・・。

Sample/Program.cs at master · bg1bgst333/Sample · GitHub
Sample/Form1.cs at master · bg1bgst333/Sample · GitHub
Sample/Form1.Designer.cs at master · bg1bgst333/Sample · GitHub