首先要在前面的事件里面添加
this.checkedListBox3.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBox3_ItemCheck);
然后在后面cs里面写:
this.checkedListBox3.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.checkedListBox3_ItemCheck);
然后在后面cs里面写:
Code
1 /**//// <summary>
2 /// checklistbox3单选
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void checkedListBox3_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
7 {
8 if (checkedListBox3.CheckedItems.Count > 0)
9 {
10 for (int i = 0; i < checkedListBox3.Items.Count; i++)
11 {
12 if (i != e.Index)
13 {
14 this.checkedListBox3.SetItemCheckState(i, System.Windows.Forms.CheckState.Unchecked);
15 }
16 }
17
18 }
19 }
1 /**//// <summary>
2 /// checklistbox3单选
3 /// </summary>
4 /// <param name="sender"></param>
5 /// <param name="e"></param>
6 private void checkedListBox3_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
7 {
8 if (checkedListBox3.CheckedItems.Count > 0)
9 {
10 for (int i = 0; i < checkedListBox3.Items.Count; i++)
11 {
12 if (i != e.Index)
13 {
14 this.checkedListBox3.SetItemCheckState(i, System.Windows.Forms.CheckState.Unchecked);
15 }
16 }
17
18 }
19 }
x单选