取消选择列表框中的项目(如何?) [英] Unselecting items in a Listbox (HOW?)

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

问题描述

嗨。


有没有办法取消选择列表框中的项目,以编程方式?

这就是我想要做的事情(我一直在努力做到这一点

调试

表格,但我没有成功)...


我有一个带有两个列表框的表格。


另外,在选项组中有两个选项按钮:1个按钮用于

第一个

列表框和1个用于otgher列表框的按钮。我们的想法是选择一个

选项按钮来启用相关的列表框。这个工作只是

罚款。但是...


假设用户选择了按钮1并启用了第一个列表框。

然后他们在第一个列表框中选择了几个项目。


然后他们决定(在点击命令按钮之前生成

查询 - 这是表单的目的)他们真正想要使用

第二个列表框。因此,他们点击

其他选项按钮,这将禁用列表框1并启用列表框2.

但是,在列表框1中选择的项目仍然是

突出显示。我希望突出显示那些突出显示的项目

(未选中)。


任何想法?

问候,

SueB


***通过开发人员指南 http: //www.developersdex.com ***

Hi.

Is there a way to "unselect" items in a listbox, programmatically?
Here''s what I want to do (and I''ve been trying to to this while
debugging
the form, but I''ve been unsuccessful) ...

I have a form with two listboxes.

The form, also, has two option buttons in an options group: 1 button for
the first
listbox and 1 button for the otgher listbox. The idea is to select an
optionbutton to enable the associated listbox. This is working just
fine. However ...

Let''s say the user selects optionbutton 1 and enables the first listbox.
Then they select a few items in the first listbox.

Then they decide (before hitting the command button to generate the
query - which is the purpose of the form) that they really want to use
the 2nd list box. So, they hit the
other option button, which will disable listbox 1 and enable listbox 2.
However, the items that were selected in listbox 1 are still
highlighted. I want to get those highlighted items unhighlighted
(unselected).

Any ideas?
Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***

推荐答案

SueB在消息中写道< OI ******** ******@news.uswest.net> :
SueB wrote in message <OI**************@news.uswest.net> :
嗨。

有没有办法取消选择列表框中的项目,以编程方式?
这就是我想要做的事情(我一直在尝试这个,同时调试表单,但我一直在不成功)...

我有一个带有两个列表框的表单。

表单也有一个选项组中的两个选项按钮:1个按钮用于
第一个
列表框和1个用于otgher列表框的按钮。我们的想法是选择一个
选项按钮来启用相关的列表框。这工作正好
。然而......

让我们说用户选择选项按钮1并启用第一个列表框。
然后他们在第一个列表框中选择几个项目。
然后他们决定(在点击命令按钮之前生成
查询 - 这是表单的目的)他们真正想要使用的第二个列表框。因此,他们点击
其他选项按钮,这将禁用列表框1并启用列表框2.
但是,列表框1中选择的项目仍然会突出显示。我想突出显示那些突出显示的项目
(未选中)。

任何想法?

问候,
SueB

***通过开发人员指南 http://www.developersdex.com 发送***
Hi.

Is there a way to "unselect" items in a listbox, programmatically?
Here''s what I want to do (and I''ve been trying to to this while
debugging
the form, but I''ve been unsuccessful) ...

I have a form with two listboxes.

The form, also, has two option buttons in an options group: 1 button for
the first
listbox and 1 button for the otgher listbox. The idea is to select an
optionbutton to enable the associated listbox. This is working just
fine. However ...

Let''s say the user selects optionbutton 1 and enables the first listbox.
Then they select a few items in the first listbox.

Then they decide (before hitting the command button to generate the
query - which is the purpose of the form) that they really want to use
the 2nd list box. So, they hit the
other option button, which will disable listbox 1 and enable listbox 2.
However, the items that were selected in listbox 1 are still
highlighted. I want to get those highlighted items unhighlighted
(unselected).

Any ideas?
Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***




对于多选列表框,我相信一种方法是重新分配

行源


me!lstList .rowsource = me!lstList.rowsource


否则我认为你可以循环列表,并设置每个项目


for l = 0 to我!lstList.listcount-1

me!lstList.selected(l)= false

next l


-

Roy-Vidar



For multiselect listboxes, I believe one way is to reassigning the
rowsource

me!lstList.rowsource = me!lstList.rowsource

Else I think you could loop the list, and set each item

for l = 0 to me!lstList.listcount-1
me!lstList.selected(l) = false
next l

--
Roy-Vidar




苏 -


试试这个(适当修改以适合你的代码):

Private Sub btnUseList2_Click()

Dim lngLoop As Long


lst1 .Enabled = False

对于lngLoop = 0到lst1.ItemsSelected.Count - 1

lst 1.Selected(lst1.ItemsSelected.Item(lngLoop))= False

下一个lngLoop

lst2.Enabled = True

End Sub


当单击启用第二个列表框的按钮时,将运行此代码;它

执行以下操作:

1)禁用第一个列表框

2)循环显示第一个列表框中的项目,选择任何

选择

3)启用第二个列表框


希望这会有所帮助!


彼得


SueB写道:

Sue -

Try this (modified appropriately to fit your code):
Private Sub btnUseList2_Click()
Dim lngLoop As Long

lst1.Enabled = False
For lngLoop = 0 To lst1.ItemsSelected.Count - 1
lst1.Selected(lst1.ItemsSelected.Item(lngLoop)) = False
Next lngLoop
lst2.Enabled = True
End Sub

This code is run when the button to enable the second list box is clicked; it
does the following:
1) Disables the first list box
2) Cycles through the items in the first list box, de-selecting any that are
selected
3) Enables the second list box

Hope this helps!

Peter

SueB wrote:
嗨。

有没有办法取消选择列表框中的项目,以编程方式?
这就是我想要做的事情(我一直在尝试这个,同时调试表单,但我一直在不成功)...

我有一个带有两个列表框的表单。

表单也有一个选项组中的两个选项按钮:1个按钮用于
第一个
列表框和1个用于otgher列表框的按钮。我们的想法是选择一个
选项按钮来启用相关的列表框。这工作正好
。然而......

让我们说用户选择选项按钮1并启用第一个列表框。
然后他们在第一个列表框中选择几个项目。
然后他们决定(在点击命令按钮之前生成
查询 - 这是表单的目的)他们真正想要使用的第二个列表框。因此,他们点击
其他选项按钮,这将禁用列表框1并启用列表框2.
但是,列表框1中选择的项目仍然会突出显示。我想突出显示那些突出显示的项目
(未选中)。

任何想法?

问候,
SueB
Hi.

Is there a way to "unselect" items in a listbox, programmatically?
Here''s what I want to do (and I''ve been trying to to this while
debugging
the form, but I''ve been unsuccessful) ...

I have a form with two listboxes.

The form, also, has two option buttons in an options group: 1 button for
the first
listbox and 1 button for the otgher listbox. The idea is to select an
optionbutton to enable the associated listbox. This is working just
fine. However ...

Let''s say the user selects optionbutton 1 and enables the first listbox.
Then they select a few items in the first listbox.

Then they decide (before hitting the command button to generate the
query - which is the purpose of the form) that they really want to use
the 2nd list box. So, they hit the
other option button, which will disable listbox 1 and enable listbox 2.
However, the items that were selected in listbox 1 are still
highlighted. I want to get those highlighted items unhighlighted
(unselected).

Any ideas?

Regards,
SueB



Roy,


感谢您的快速回复。我会尝试两种方法,看看

最适合我。


问候,

SueB


***通过开发人员指南 http://www.developersdex发送。 com ***
Roy,

Thank you for the quick reply. I''ll give both methods a try and see
which works best for me.

Regards,
SueB

*** Sent via Developersdex http://www.developersdex.com ***


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

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