单击 CheckBox 时,我需要选择 ListBox 中的所有项目.是否可以使用一行代码选择 ListBox 中的所有项目?还是我必须遍历所有项目并将每个项目的 selected 设置为 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.
这篇关于如何在选中复选框时选择列表框中的所有项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!