VB.net中listbox输出到textbox并清空上一个结果
VB.net中listbox编辑的字符串,点击一个后字符串相应的值输出到textbox中,点击下一个字符串清空上一个输出在textbox中的值。...
VB.net中listbox编辑的字符串,点击一个后字符串相应的值输出到textbox中,点击下一个字符串清空上一个输出在textbox中的值。
展开
1个回答
展开全部
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 1 To 10
ListBox1.Items.Add(i)
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = ListBox1.Text
End Sub
更多追问追答
追问
您理解错了,我的意思是比如我在listbox中点击了1,1的值为2,在textbox中要显示1的值,
追答
Dim a(9)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i = 1 To 10
ListBox1.Items.Add(i)
a(i - 1) = "内容" & i
Next
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
TextBox1.Text = a(ListBox1.SelectedIndex)
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询