ヘッダー

VB.NET2002対応 VB.NET2003対応 VB2005対応

 

選択されている項目を取得する

1.選択されている項目を1つ取得する例

VB.NET2002対応 VB.NET2003対応 VB2005対応


TextBox1.Text = ListBox1.SelectedItem
 

 

2.選択されている項目のインデックスを1つ取得する例

VB.NET2002対応 VB.NET2003対応 VB2005対応


TextBox1.Text = ListBox1.SelectedIndex
 

 

3.すべての選択されている項目を取得する例

VB.NET2002対応 VB.NET2003対応 VB2005対応

Dim oItem As Object

For Each oItem In ListBox1.SelectedItems
    Label1.Text &= oItem & vbNewLine
Next

 

4.すべての選択されている項目のインデックスを取得する例

VB.NET2002対応 VB.NET2003対応 VB2005対応

Dim Index As Integer

For Each Index In ListBox1.SelectedIndices
    Label1.Text &= Index & ", "
Next