如何选中复选框中列表框中的所有项目? [英] How do I select all items in a listbox on checkbox checked?

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

问题描述

单击复选框时,我需要选择列表框中的所有项目.是否可以使用单行代码选择ListBox中的所有项目?还是我必须遍历所有项目并为每个项目将其设置为true?

I need to select all items in a ListBox when a CheckBox is clicked. Is it possible to select all items in the ListBox using a single line of code? Or will I have to loop through all items and set selected to true for each one of them?

推荐答案

我认为您必须在这里循环.一次选择所有项目是一个非常特定(且可能很少)的用例,即开箱即用地提供该功能毫无意义.此外,循环还是只有两行代码.

I think you have to loop here. Selecting all items at once is a pretty specific (and probably rare) use case where it simply makes no sense to offer that functionality out of the box. Furthermore, the loop will be just two lines of code anyway.

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

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