如何拥有“全部”或“没有选择意味着全部”或我的列表框过滤器上的选项? [英] How to have a "All" or "No selection means all" option on my Listbox Filter?

查看:52
本文介绍了如何拥有“全部”或“没有选择意味着全部”或我的列表框过滤器上的选项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好! / span>



我正在学习自己的VBA随着我的进展,我一直在做一个好的工作,但我坚持一件事。到目前为止,我
创建了一个带有列表框的表单,该列表框充当查询的过滤器。如果您点击"城市"扬克斯,伍德赛德和牙买加,然后过滤按钮 - 只有那些城市的属性出现。




我想要一个"全部"按钮或条件,声明如果没有选择,选择所有,但我不能想象它
out或找到任何适合我的东西。




这是我现在的代码:

Hello everyone!

I'm learning VBA on my own sort of as I go along, and I've been doing an okay job but I'm stuck on one thing. So far I have created a form with a list box that acts as a filter to a query. If you click in "cities" Yonkers, Woodside and Jamaica and then the filter button - only properties with those cities come up.

I want an "All" button or a condition that states that if none are selected, select all but I cant figure it out or find anything that works for me.

Here is my code right now:


代码:

推荐答案

有一个名为ItemsSelected的集合,它只包含ListBox中已选择的项目。您可以检查计数(ListBox.ItemsSelected.Count)以确定当前是否选择了任何项目。如果没有选择,则
可以迭代ListBox并将每个ListBox项的Selected属性设置为True。
There is a collection called ItemsSelected, which only contains the items in the ListBox that have been selected. You can check the count (ListBox.ItemsSelected.Count) to determine whether any items are currently selected. If none are selected then you can iterate through the ListBox and set the Selected property for each ListBox item to True.


这篇关于如何拥有“全部”或“没有选择意味着全部”或我的列表框过滤器上的选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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