listbox的全选\全部选\反选C#
//全选方法一
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);
}
}
}