实现一、
实现二、
- 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());
- }
本文介绍两种从CheckedListBox中获取所有被选中项的方法,并展示如何使用这些数据填充一个列表及显示列表内容。

4412

被折叠的 条评论
为什么被折叠?



