如何取消选择ListBox的选定项目? [英] How to unselect ListBox's selected item ?

查看:627
本文介绍了如何取消选择ListBox的选定项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Win Form中,我有三个ListBox。我必须一次只选择一个列表框的日期并单击一个按钮。该按钮将根据所选ListBox的任何一个项执行某些任务。  但如果我选择一个列表框,那么在下一刻我选择
另一个列表框,然后前一个列表框的数据仍然被选中,它不会被取消选择。这会导致问题。

In my Win Form i have three ListBox. I have to select only one listbox's date at a time and Click a button. That button will perform some task based of any one of the selected ListBox's items.  But if i select a list box, then at the next moment i select another listbox then previous listbox's data remains selected,it is not unselected.This causes problem.

如何解决我的这个问题?

How to solve my this problem ?

推荐答案

您可以尝试以下方法:
You could try something like:

Private Sub Listbox1_SelectedIndexChanged()
Listbox2.selectedindex = -1
Listbox3.selectedindex = -1
end sub

Private Sub Listbox2_SelectedIndexChanged()
Listbox1.selectedindex = -1
Listbox3.selectedindex = -1
end sub

Private Sub Listbox3_SelectedIndexChanged()
Listbox2.selectedindex = -1
Listbox1.selectedindex = -1
end sub


这篇关于如何取消选择ListBox的选定项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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