我需要循环遍历一个已勾选的列表框,对其中的每个项目进行检查(基本上像“全选”功能)。
你能给我提供一个基本示例来帮助我吗?
我需要循环遍历一个已勾选的列表框,对其中的每个项目进行检查(基本上像“全选”功能)。
你能给我提供一个基本示例来帮助我吗?
SetSelected
并迭代所有Items
。// Loop through and set all to selected.
for (int x = 0; x < listBox1.Items.Count; x++)
{
listBox1.SetSelected(x, true);
}
要检查项目,请使用SetItemChecked
。
// Loop through and set all to checked.
for (int x = 0; x < listBox1.Items.Count; x++)
{
listBox1.SetItemChecked(x, true);
}
foreach (ListItem li in CheckBoxList1.Items)
{
li.Selected = true;
}