3 Star 17 Fork 8

独立观察员/Practice

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
FormCkl.cs 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace WinFormPractice
{
public partial class FormCkl : Form
{
public FormCkl()
{
InitializeComponent();
}
private void btnCheck_Click(object sender, EventArgs e)
{
if (ckl1.CheckedItems.Contains("1") && ckl1.CheckedItems.Contains("3"))
{
MessageBox.Show("OK");
}
else
{
MessageBox.Show("不OK");
}
}
/// <summary>
/// dlgcy:获取CheckedListBox选中项List;
/// </summary>
private List<T> GetCheckedListBoxCheckedList<T>(CheckedListBox ckl)
{
List<T> list = new List<T>();
foreach (var item in ckl.CheckedItems)
{
list.Add((T)item);
}
return list;
}
private void btnCheck2_Click(object sender, EventArgs e)
{
List<string> checkedList = GetCheckedListBoxCheckedList<string>(ckl1);
List<string> compareList = new List<string>(){"1", "3"};
if(checkedList.All(compareList.Contains) && checkedList.Count == compareList.Count)
{
MessageBox.Show("OK");
}
else
{
MessageBox.Show("不OK");
}
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/dlgcy/Practice.git
git@gitee.com:dlgcy/Practice.git
dlgcy
Practice
Practice
master

搜索帮助