上下移动多个列表框项目 [英] Moving multiple Listbox items up and down

查看:68
本文介绍了上下移动多个列表框项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





如何向上移动并向下移动列表框中的多个列表框项目。



谢谢和问候,

GSS

Hi,

How to move up and move down multiple listbox items within the listbox.

Thanks and Regards,
GSS

推荐答案

试试这个

try this
Private Sub UpClick()
	' only if the first item isn't the current one
	If listBox1.ListIndex > 0 Then
		' add a duplicate item up in the listbox
		listBox1.AddItem(listBox1.Text, listBox1.ListIndex - 1)
		' make it the current item
		listBox1.ListIndex = (listBox1.ListIndex - 2)
		' delete the old occurrence of this item
		listBox1.RemoveItem(listBox1.ListIndex + 2)
	End If
End Sub

Private Sub DownClick()
	' only if the last item isn't the current one
	If (listBox1.ListIndex <> -1) AndAlso (listBox1.ListIndex < listBox1.ListCount - 1) Then
		' add a duplicate item down in the listbox
		listBox1.AddItem(listBox1.Text, listBox1.ListIndex + 2)
		' make it the current item
		listBox1.ListIndex = listBox1.ListIndex + 2
		' delete the old occurrence of this item
		listBox1.RemoveItem(listBox1.ListIndex - 2)
	End If
End Sub


这篇关于上下移动多个列表框项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆