新闻资讯

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻资讯列表

vb怎么把list选中的项删除,vb list选中项

发布时间:2024-03-16 20:48:52

vb怎样把list选中的项删除

在VB中,你可使用以下代码来删除List当选中的项:

If ListBox1.SelectedIndex <> ⑴ Then
    ListBox1.Items.RemoveAt(ListBox1.SelectedIndex)
End If

上面的代码首先检查ListBox中是否是有选中的项(索引不为⑴),然后使用RemoveAt方法删除选中的项。请确保将代码放在触发删除操作的事件中,例如按钮点击事件。