实现一、
实现二、
- for (int i = 0; i < ChkRolelist.ItemCount; i++)
- {
- if (ChkRolelist.GetItemChecked(i))
- {
- _listRole.Add(ChkRolelist.GetItemValue(i).ToString());
- }
- }
实现二、
- foreach (CheckedListBoxItem var in this.ChkRolelist.Items)
- {
- if (var.CheckState == CheckState.Checked)
- {
- _listRole.Add(var.Value.ToString());
- }
- }
- for (int i = 0; i < _listRole.Count; i++)
- {
- MessageBox.Show(_listRole[i].ToString());
- }