0
所以我想在vb.net 2010中有一個列表框的代碼。Vb.Net 2010列表框
例如:
1) Apple
2) Pizza
3) Juice
如何將顯示行號2或任何其他的用戶 - 我試圖與這樣的標籤盒做 Label1.Text = ListBox1.Text(2) - 不起作用。
所以我想在vb.net 2010中有一個列表框的代碼。Vb.Net 2010列表框
例如:
1) Apple
2) Pizza
3) Juice
如何將顯示行號2或任何其他的用戶 - 我試圖與這樣的標籤盒做 Label1.Text = ListBox1.Text(2) - 不起作用。
Label1.Text = ListBox1.Items(1).ToString()
,如果你想獲得當前所選項目的文本,那麼你可以做
If ListBox1.SelectedItem IsNot Nothing
Label1.Text = ListBox1.SelectedItem.ToString()
End If
MsgBox("List box item 1: " & ListBox1.Items(0), MsgBoxStyle.Information)
MsgBox("List box item 2: " & ListBox1.Items(1), MsgBoxStyle.Information)
MsgBox("List box item 3: " & ListBox1.Items(2), MsgBoxStyle.Information)