而不是使用Text
的{{1}}属性我试图使用ListBox
属性,这样当我在一个列表框中选择某个名称时,项目会被添加到另一个列表框中列表框。这是我目前正在使用的代码。
SelectedIndex
如果我使用的是Ward = ListBox1.SelectedIndex
ListBox2.Items.Clear()
Select Case Ward
Case
ListBox2.Items.Add("Fred Jones")
ListBox2.Items.Add("John Green")
ListBox2.Items.Add("Imran Shah")
属性,那么情况就是"弗莱明",但如果我使用Text
属性,该怎么办?
答案 0 :(得分:0)
好吧,因为SelectedIndex
是一个整数,你的情况就是这样:
Ward = ListBox1.SelectedIndex
ListBox2.Items.Clear()
Select Case Ward
Case 1
ListBox2.Items.Add("Fred Jones")
ListBox2.Items.Add("John Green")
ListBox2.Items.Add("Imran Shah")
我不知道这是否是最好的方法。如果您的索引在以后更改,您的案例将被抛弃。你可能想坚持使用文字。