如何选择ListBox中的最后一个项目

zhxiongying 2005-02-25 06:45:21
如何选择ListBox中的最后一个项目
还有如何删除选中的项目和他以下的项目
...全文
264 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
xdwlb 2005-02-27
  • 打赏
  • 举报
回复
删除:
i = ListBox1.SelectedIndex
For j = 1 To ListBox1.Items.Count - i
ListBox1.Items.RemoveAt(i)
Next
xdwlb 2005-02-27
  • 打赏
  • 举报
回复
if listbox1.items.count>0 then
listbox1.selectedindex=listbox1.items.count-1
endif
hamadou 2005-02-26
  • 打赏
  • 举报
回复
选择ListBox中的最后一个项目:
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
删除选中的项目和他以下的项目:
i = ListBox1.SelectedIndex
For j = 1 To ListBox1.Items.Count - i
ListBox1.Items.RemoveAt(i)
Next
softbugg 2005-02-25
  • 打赏
  • 举报
回复
选择ListBox中的最后一个项目
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
删除
i = ListBox1.SelectedIndex
For j = ListBox1.Items.Count - i to i Step -1
ListBox1.Items.RemoveAt(i)
Next
注解:??
可使用ToolTip 类
zhxiongying 2005-02-25
  • 打赏
  • 举报
回复
还有我要在ListBox的项目中添加注解(注解可选择),在选择一个项目后如果有注解就将注解显示出来,要如何做呀
daisy8675 2005-02-25
  • 打赏
  • 举报
回复
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
With Me.ListBox1
.Items().Add("111")
.Items().Add("222")
.Items().Add("333")
.Items().Add("444")
.Items().Add("555")
End With
End Sub
'选择操作
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.ListBox1().SetSelected(Me.ListBox1.Items.Count - 1, True)
End Sub
'删除操作
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
For i = 0 To Me.ListBox1.Items.Count - 1
If Me.ListBox1.GetSelected(i) = True Then
Me.ListBox1.Items.RemoveAt(i)
Exit For
End If
Next

End Sub
点点星灯 2005-02-25
  • 打赏
  • 举报
回复
Me.ListBox1.SelectedIndex = ListBox1.Items.Count - 1
xiaohuasz 2005-02-25
  • 打赏
  • 举报
回复
选择ListBox中的最后一个项目:
ListBox1.SelectedIndex = ListBox1.Items.Count - 1
删除选中的项目和他以下的项目:
i = ListBox1.SelectedIndex
For j = 1 To ListBox1.Items.Count - i
ListBox1.Items.RemoveAt(i)
Next

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧