使用WinForms检查列表框 [英] Checked ListBox using WinForms
本文介绍了使用WinForms检查列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友,
如何从数据库中获取字符串,以及字符串在某种意义上是否匹配,请使清单框选中项目.
如果可能,我需要代码...
我正在使用WinForms
在此先感谢...
Dear Friends,
How to get string from database, and if the strings are match in the sense make the checkedlistbox checkeditems.
If possible I need code...
I''m using WinForms
Thanks in Advance...
推荐答案
使用以下方法
-----------------
Use below method
-----------------
DataTable dt = GetTables(); ;
string listItems=String.Empty;
dt.AsEnumerable().ToList<DataRow>().ForEach(Obj => listItems += ","+Obj["ColName"].ToString());
listItems = listItems + ",";
for (int i = 0; i < objchListBox.Items.Count; i++)
{
if (listItems.Contains("," + objchListBox.Items[i].ToString() + ","))
objchListBox.SetItemChecked(i, true);
else
objchListBox.SetItemChecked(i, false);
}
这篇关于使用WinForms检查列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文