爱满家园我的小手印:请问vb中如何能让列表框里的条目改变次序,使其能上下移动

来源:百度文库 编辑:中科新闻网 时间:2024/05/10 00:48:47
悬赏20

建立两个CommandButton,将他们设为数组,然后:
Private Sub Command1_Click(Index As Integer)
On Error GoTo handle
With List1
For i = 0 To List1.ListCount - 1
If .Selected(i) Then
If Index = 0 Then
.AddItem List1.List(i), i - 1
.RemoveItem i + 1
.Selected(i - 1) = True
Else
.AddItem List1.List(i), i + 2
.RemoveItem i
.Selected(i + 1) = True
End If
Exit For
End If
Next
End With
handle: Exit Sub
End Sub

删除列表框的指定项目
list1.removeitem index
添加项目
list1.additem "要加的项目名",index

index为列表框中项目的标号
第一个项目为0,其他的以此类推

有了上面两个方法,再加上你的聪明才智
相信一定会解决这个问题的
有什么问题再联系我吧~