//全选方法一
private void SelectAll(ListBox ListBox)
...{
for (int i = 0; i < ListBox.Items.Count; i++)
...{
ListBox.SelectedIndex = i;
}
}
//全选方法一和全不选
private void SelectAll(ListBox ListBox,bool b)
...{
for (int i = 0; i < ListBox.Items.Count; i++)
...{
ListBox.SetSelected(i, b);
}
}
//反选
private void unSelectAll(ListBox ListBox)
...{
bool b;
for (int i = 0; i < ListBox.Items.Count; i++)
...{
b = !ListBox.GetSelected(i);
ListBox.SetSelected(i, b);
}
}
文章出处:http://www.diybl.com/course/4_webprogram/asp.net/netjs/20071020/78398.html