Private Sub Form_Load() Me.List1.AddItem "a1" Me.List1.AddItem "a2" Me.List1.AddItem "a3" Me.List1.AddItem "a4" Me.List1.AddItem "a5" Me.List1.AddItem "a6" Me.List1.AddItem "a7" End SubPrivate Sub List1_DblClick() If Me.List1.ListCount < 1 Then Exit Sub Me.List2.AddItem Me.List1.List(Me.List1.ListIndex) Me.List1.RemoveItem Me.List1.ListIndex Me.List2.Refresh Me.List2.NewIndex End SubPrivate Sub List2_DblClick() If Me.List2.ListCount < 1 Then Exit Sub Me.List1.AddItem Me.List2.List(Me.List2.ListIndex) Me.List2.RemoveItem Me.List2.ListIndex Me.List1.Refresh End Sub
Me.List1.AddItem "a1"
Me.List1.AddItem "a2"
Me.List1.AddItem "a3"
Me.List1.AddItem "a4"
Me.List1.AddItem "a5"
Me.List1.AddItem "a6"
Me.List1.AddItem "a7"
End SubPrivate Sub List1_DblClick()
If Me.List1.ListCount < 1 Then Exit Sub
Me.List2.AddItem Me.List1.List(Me.List1.ListIndex)
Me.List1.RemoveItem Me.List1.ListIndex
Me.List2.Refresh
Me.List2.NewIndex
End SubPrivate Sub List2_DblClick()
If Me.List2.ListCount < 1 Then Exit Sub
Me.List1.AddItem Me.List2.List(Me.List2.ListIndex)
Me.List2.RemoveItem Me.List2.ListIndex
Me.List1.Refresh
End Sub
.RemoveItem
就用这两个方法就ok
AddItem 方法
用于将项目添加到 ListBox 或 ComboBox 控件,或者将行添加到 MS Flex Grid 控件。不支持命名参数。语法object.AddItem item, indexAddItem 方法的语法包含下列部分::部分 描述
object 必需的。一个对象表达式,其值为“应用于”列表中的一个对象。
Item 必需的。字符串表达式,它用来指定添加到该对象的项目。这仅仅对于 MS Flex Grid 控件,才能使用 tab字符(字符代码 09)分隔将要插入到新添加行中每列的多重字符串。
Index 可选的。是整数,它用来指定新项目或行在该对象中的位置。对于 ListBox 或 ComboBox 控件的首项,或者对于 MS Flex Grid 控件的首行,index 为 0。
说明如果所给出的 index 值有效,则 item 将放置在 object 中相应的位置。如果省略 index,当 Sorted 属性设置为 True 时,item 将添加到恰当的排序位置,当 Sorted 属性设置为 False 时, item 将添加到列表的结尾。绑定到 Data 控件的 ListBox 或 ComboBox 控件不支持 AddItem 方法。
RemoveItem 方法
用以从 ListBox 或 ComboBox 控件中删除一项,或从 MS Flex Grid 控件中删除一行。不支持命名参数。语法object.RemoveItem indexRemoveItem 方法的语法包含下列部分:部分 描述
object 必需的。一个对象表达式,其值为“应用于”列表中的一个对象。
index 必需的。一个整数,它表示要删除的项或行在对象中的位置。对于 ListBox 或 ComboBox 中的首项或 MS Flex Grid 控件中的首行,index = 0。
说明被绑定到 Data 控件的 ListBox 或 ComboBox 不支持 RemoveItem 方法。