列表框地狱 [英] listbox hell
问题描述
好的,星期五,我正在工作,我无法让它工作:
我在一个标签控制页面上有3个列表框。当我在
listbox1中选择一个项目时,我想要在其他2个列表框中选择的任何内容
未选中。当选择listbox2时,1和3应该没有项目
选择和listbox 3相同。
听起来很简单......应该很简单!我已经尝试了
listbox [x] .clearselected(),listbox [x] .selectedindex = -1并用大棒击败它b / b
。但到目前为止似乎没有任何效果。对于前3次鼠标点击似乎是
工作,然后开始在每个列表框中选择一个
!我已将上述命令添加到mousedown,
mouseclick,selectedindexchanged以及我能想到的所有其他事件
以便根除此问题但没有成功,所以我是问你
如果你知道其他任何方式可以做到这一点吗?
谢谢
戴夫
Ok, its a friday, I''m at work and I cant get this to work:
I have 3 listboxes on one tab control page. when i select an item in
listbox1 i want whatever is selected on the other 2 listboxes
unselected. when listbox2 is selected, 1 and 3 should have no items
selected and the same with listbox 3.
Sounds simple... should be simple! I have tried
listbox[x].clearselected(), listbox[x].selectedindex=-1 and beating it
with a large stick. But so far nothing seems to work. It appears to
work for the first 3 mouse clicks and then starts selecting one on
each listbox! I have added the above commands to the mousedown,
mouseclick, selectedindexchanged and every other event i can think of
in order to erradicate this problem with no success, so i am ask you
if you know of any other way of being able to do this?
Thanks
Dave
推荐答案
在每个列表框的GotFocus事件中,您应该能够清除另一个
两个列表框。如果这不起作用,那么我会对它是如何完成它的兴趣。
Dave Sauny写道:
In the GotFocus event of each listbox, you should be able to clear the other
two listboxes. If this doesn''t work, then I would be interested in how it
can be done.
"Dave Sauny" wrote:
好的,星期五,我在工作,我不能让它工作:
我有一个选项卡控件上有3个列表框页。当我选择
listbox1中的一个项目时,我想要在其他2个列表框中选择的任何内容
未选中。当选择listbox2时,1和3应该没有选择的项目和列表框3相同。
听起来很简单......应该很简单!我已经尝试了
listbox [x] .clearselected(),listbox [x] .selectedindex = -1并用大棒击打它。但到目前为止似乎没有任何效果。它似乎适用于前3次鼠标点击,然后开始在每个列表框中选择一个!我已将上述命令添加到mousedown,
mouseclick,selectedindexchanged以及我能想到的所有其他事件
以消除此问题但没有成功,所以我问你
如果你知道其他任何能够做到这一点的方法吗?
戴夫
Ok, its a friday, I''m at work and I cant get this to work:
I have 3 listboxes on one tab control page. when i select an item in
listbox1 i want whatever is selected on the other 2 listboxes
unselected. when listbox2 is selected, 1 and 3 should have no items
selected and the same with listbox 3.
Sounds simple... should be simple! I have tried
listbox[x].clearselected(), listbox[x].selectedindex=-1 and beating it
with a large stick. But so far nothing seems to work. It appears to
work for the first 3 mouse clicks and then starts selecting one on
each listbox! I have added the above commands to the mousedown,
mouseclick, selectedindexchanged and every other event i can think of
in order to erradicate this problem with no success, so i am ask you
if you know of any other way of being able to do this?
Thanks
Dave
戴夫,
我知道这个样本符合你的要求。
我为此做了,所以当我需要添加评论时,告诉它比我会做的那样
,但是当你理解它的时候,总是有点看起来好像
有点傻..
>
\\\
Private Sub Form1_Load(ByVal sender As System.Object,_
ByVal e As System.EventArgs)处理MyBase.Activated
For each ctr As Control in Me.Controls
如果TypeOf ctr是ListBox那么
DirectCast(ctr,ListBox).SelectionMode _
= SelectionMode.MultiExtended
AddHandler DirectCast(ctr,ListBox).SelectedIndexChanged,_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
结束Sub
私有子ListBox_SelectedIndexChanged(ByVal发送者为_
System.Object,ByVal e As System.EventArgs)
For each ctr As Control In Me。控件
如果TypeOf ctr是ListBox那么
RemoveHandler DirectCast(ctr,ListBox).SelectedIndexChanged,
_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
选择案例DirectCast(发件人,列表框)。名称
案例" ListBox1"
For i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i,False)
Next
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i,False)
下一页
Case" ListBox2"
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SetSelected(i,F alse)
下一页
我的整数= 0到ListBox3.Items.Count - 1
ListBox3.SetSelected(i,False)
下一页
Case" ListBox3"
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i,False)
下一页
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2。 SetSelected(i,False)
下一页
结束选择
For Each ctr As Control in Me.Controls
如果TypeOf ctr是ListBox那么
AddHandler DirectCast(ctr,ListBox).SelectedIndexChanged,_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
///
我希望这有帮助吗?
Cor
" Dave Sauny" <哒******* @ gmail.com> schreef in bericht
新闻:5a ************************** @ posting.google.c om ...
Dave,
I have the idea that this sample does what you ask.
I made it for this, so when I need to add comments, tell it than I will do
that, however when you understand it, than that looks for me always a little
bit silly..
\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
DirectCast(ctr, ListBox).SelectionMode _
= SelectionMode.MultiExtended
AddHandler DirectCast(ctr, ListBox).SelectedIndexChanged, _
AddressOf ListBox_SelectedIndexChanged
End If
Next
End Sub
Private Sub ListBox_SelectedIndexChanged(ByVal sender As _
System.Object, ByVal e As System.EventArgs)
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
RemoveHandler DirectCast(ctr, ListBox).SelectedIndexChanged,
_
AddressOf ListBox_SelectedIndexChanged
End If
Next
Select Case DirectCast(sender, ListBox).Name
Case "ListBox1"
For i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
Case "ListBox2"
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i, False)
Next
Case "ListBox3"
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
End Select
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
AddHandler DirectCast(ctr, ListBox).SelectedIndexChanged, _
AddressOf ListBox_SelectedIndexChanged
End If
Next
///
I hope this helps?
Cor
"Dave Sauny" <da*******@gmail.com> schreef in bericht
news:5a**************************@posting.google.c om...
好的,星期五,我正在工作,我无法让它工作:
我在一个标签控制页面上有3个列表框。当我选择
listbox1中的一个项目时,我想要在其他2个列表框中选择的任何内容
未选中。当选择listbox2时,1和3应该没有选择的项目和列表框3相同。
听起来很简单......应该很简单!我已经尝试了
listbox [x] .clearselected(),listbox [x] .selectedindex = -1并用大棒击打它。但到目前为止似乎没有任何效果。它似乎适用于前3次鼠标点击,然后开始在每个列表框中选择一个!我已将上述命令添加到mousedown,
mouseclick,selectedindexchanged以及我能想到的所有其他事件
以消除此问题但没有成功,所以我问你
如果你知道其他任何能够做到这一点的方法吗?
戴夫
Ok, its a friday, I''m at work and I cant get this to work:
I have 3 listboxes on one tab control page. when i select an item in
listbox1 i want whatever is selected on the other 2 listboxes
unselected. when listbox2 is selected, 1 and 3 should have no items
selected and the same with listbox 3.
Sounds simple... should be simple! I have tried
listbox[x].clearselected(), listbox[x].selectedindex=-1 and beating it
with a large stick. But so far nothing seems to work. It appears to
work for the first 3 mouse clicks and then starts selecting one on
each listbox! I have added the above commands to the mousedown,
mouseclick, selectedindexchanged and every other event i can think of
in order to erradicate this problem with no success, so i am ask you
if you know of any other way of being able to do this?
Thanks
Dave
干杯cor,我不知道有一个setSelected方法,它已经是amonday早上的救生员了!欢呼
" Cor Ligthert" <无************ @ planet.nl>在消息新闻中写道:< #h ************** @ TK2MSFTNGP10.phx.gbl> ...
cheers cor, i didnt know there was a setSelected method, it has been a
life saver on amonday morning! cheers
"Cor Ligthert" <no************@planet.nl> wrote in message news:<#h**************@TK2MSFTNGP10.phx.gbl>...
Dave,
>我认为这个样本符合你的要求。
我是为此而做的,所以当我需要添加评论时,告诉它比我会做的那样
然而当你理解它,比那个看起来总是有点傻傻......
\\\
Private Sub Form1_Load(ByVal sender As System.Object,_ < byVal e As System.EventArgs)处理MyBase.Activated
为每个ctr作为控件在Me.Controls
如果TypeOf ctr是ListBox那么
DirectCast(ctr,ListBox).SelectionMode _
= SelectionMode.MultiExtended
AddHandler DirectCast(ctr,ListBox).SelectedIndexChanged,_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
结束子
Private Sub ListBox_SelectedIndexChanged(ByV al sender as _
System.Object,ByVal e As System.EventArgs)
For Each ctr As Control in Me.Controls
如果TypeOf ctr是ListBox那么
RemoveHandler DirectCast(ctr ,ListBox).SelectedIndexChanged,
_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
Select Case DirectCast(sender,ListBox).Name
Case" ListBox1" ;对于我作为整数= 0到ListBox3.Items.Count - 1
ListBox3.SetSelected(i,False)
对于我作为整数= 0到ListBox2.Items .Count - 1
ListBox2.SetSelected(i,False)
下一个
Case" ListBox2"
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SetSelected(i,False)
下一页
对于i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i,False)
下一个
Case" ListBox3"
对于i as Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i,False)
对于i as Integer = 0到ListBox2.Items.Count - 1
ListBox2.SetSelected (i,False)
下一页
结束选择
为每个ctr作为控件在Me.Controls
如果TypeOf ctr是ListBox那么
AddHandler DirectCast(ctr,ListBox) .SelectedIndexChanged,_
AddressOf ListBox_SelectedIndexChanged
结束如果
下一页
///
我希望这有帮助吗?
Cor
Dave Sauny <哒******* @ gmail.com> schreef in bericht
新闻:5a ************************** @ posting.google.c om ...
Dave,
I have the idea that this sample does what you ask.
I made it for this, so when I need to add comments, tell it than I will do
that, however when you understand it, than that looks for me always a little
bit silly..
\\\
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Activated
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
DirectCast(ctr, ListBox).SelectionMode _
= SelectionMode.MultiExtended
AddHandler DirectCast(ctr, ListBox).SelectedIndexChanged, _
AddressOf ListBox_SelectedIndexChanged
End If
Next
End Sub
Private Sub ListBox_SelectedIndexChanged(ByVal sender As _
System.Object, ByVal e As System.EventArgs)
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
RemoveHandler DirectCast(ctr, ListBox).SelectedIndexChanged,
_
AddressOf ListBox_SelectedIndexChanged
End If
Next
Select Case DirectCast(sender, ListBox).Name
Case "ListBox1"
For i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
Case "ListBox2"
For i As Integer = 0 To ListBox1.Items.Count - 1
ListBox1.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox3.Items.Count - 1
ListBox3.SetSelected(i, False)
Next
Case "ListBox3"
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
For i As Integer = 0 To ListBox2.Items.Count - 1
ListBox2.SetSelected(i, False)
Next
End Select
For Each ctr As Control In Me.Controls
If TypeOf ctr Is ListBox Then
AddHandler DirectCast(ctr, ListBox).SelectedIndexChanged, _
AddressOf ListBox_SelectedIndexChanged
End If
Next
///
I hope this helps?
Cor
"Dave Sauny" <da*******@gmail.com> schreef in bericht
news:5a**************************@posting.google.c om...
好的,星期五,我在工作,我不能让它工作:
我在一个标签控制页面上有3个列表框。当我选择
listbox1中的一个项目时,我想要在其他2个列表框中选择的任何内容
未选中。当选择listbox2时,1和3应该没有选择的项目和列表框3相同。
听起来很简单......应该很简单!我已经尝试了
listbox [x] .clearselected(),listbox [x] .selectedindex = -1并用大棒击打它。但到目前为止似乎没有任何效果。它似乎适用于前3次鼠标点击,然后开始在每个列表框中选择一个!我已将上述命令添加到mousedown,
mouseclick,selectedindexchanged以及我能想到的所有其他事件
以消除此问题但没有成功,所以我问你
如果你知道其他任何方法吗?
Dave
Ok, its a friday, I''m at work and I cant get this to work:
I have 3 listboxes on one tab control page. when i select an item in
listbox1 i want whatever is selected on the other 2 listboxes
unselected. when listbox2 is selected, 1 and 3 should have no items
selected and the same with listbox 3.
Sounds simple... should be simple! I have tried
listbox[x].clearselected(), listbox[x].selectedindex=-1 and beating it
with a large stick. But so far nothing seems to work. It appears to
work for the first 3 mouse clicks and then starts selecting one on
each listbox! I have added the above commands to the mousedown,
mouseclick, selectedindexchanged and every other event i can think of
in order to erradicate this problem with no success, so i am ask you
if you know of any other way of being able to do this?
Thanks
Dave
这篇关于列表框地狱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!