开发者

Vb.Net 2010 ListBox

So I am trying to code something in vb.net 2010 which will have a list box.

For example:

1) Apple 
2) Pizza
3) Juice

How would I display Line number 2 or any other to the user - I tried doing it with a label box开发者_StackOverflow like this Label1.Text = ListBox1.Text(2) - does not work.


Label1.Text = ListBox1.Items(1).ToString()

if you want to get the Text of the currently selected item then you can do

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜