我知道我可以遍历 checkboxlist.Items
并查看是否没有选择任何项目,但是在后面的代码中是否有更好的方法来查明是否没有选择任何项目?
最佳答案
您必须检查 SelectedIndex。如果等于-1,则表示未选择任何内容。
CheckBoxList list = new CheckBoxList();
if (list.SelectedIndex == -1)
{
//Nothing is selected
}
https://stackoverflow.com/questions/7271980/