如何取得和设置 CheckedListBox 中的值 有一个 CheckedListBox 控件,如何将多选取得的值以"xxx3,xxx6,xxx8,xxx19"这种string的形式存在数据库里?有没有办法在Load事件中,跟据提取出来的string恢复CheckedListBox控件中已有的项? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CheckedIndices 该 CheckedListBox 中选中索引的集合。 CheckedItems 该 CheckedListBox 中选中项的集合。 从这两个属性中获取,或者设置这两个属性 1.string strString="";for(int i=0;i<CheckedListBox.Items.Count;i++){ if(CheckedListBox.Items[i].Selected) { strString += CheckedListBox.SelectedValue.ToString() + ','; }}2.string [] strSelect = strString.Split(',');for (int i=0;i<strSelect.Length;i++){ for(int j=0;j<CheckedListBox.Items.Count;j++) { if(CheckedListBox.Items[j].ToString == strSelect[i]) { CheckedListBox.Items[j].Selected; } }} string s=""; foreach(object o in this.checkedListBox1.CheckedItems) { s+=o.ToString()+","; //this.Text=s.Substring(0,s.Length-1); } string [] strSelect = strString.Split(',');for (int i=0;i<strSelect.Length;i++){ for(int j=0;j<CheckedListBox.Items.Count;j++) { if(CheckedListBox.Items[j].ToString == strSelect[i]) { CheckedListBox.Items[j].Selected; } }}这一个不对哦,没有Selected这个属性的。 不好意思,我写的是web下面的如果是win的话就是CheckedItems了 checkedListBox1.DataSource=ds.Tables[0];checkedListBox1.ValueMember="intSectionID";checkedListBox1.DisplayMember="txtShortDesc".ToString();for (int i = 0;i<checkedListBox1.CheckedItems.Count;i++){ DataRowView dv = ((System.Data.DataRowView)checkedListBox1.CheckedItems[i]); aa+=dv["字段"].ToString()+";"} 怎么样排序。。求高手啊!!! 提高此循环的速度 春节散分(随便问下怎么拥有自己的网站 ) 怎么给文本后边加上回车(换行符) 有关vs C# propertyGrid的问题 向大家请假几个问题,会的帮忙解决一下,不会的也来帮忙顶顶!! 弹出的窗体置于应用程序的最顶层(激活)??? DataTimerPicter中时间格式的问题 做一个代码生成器,老师叫我去了解C#如何获取所有数据库中的表? WPF,DataGrid如何设置列标题分割线的颜色 如何让WinForm中的某一个单元格不可编辑?(进者有分) .net 4.0 ,路由二级域名
CheckedItems 该 CheckedListBox 中选中项的集合。
从这两个属性中获取,或者设置这两个属性
string strString="";
for(int i=0;i<CheckedListBox.Items.Count;i++)
{
if(CheckedListBox.Items[i].Selected)
{
strString += CheckedListBox.SelectedValue.ToString() + ',';
}
}
2.
string [] strSelect = strString.Split(',');
for (int i=0;i<strSelect.Length;i++)
{
for(int j=0;j<CheckedListBox.Items.Count;j++)
{
if(CheckedListBox.Items[j].ToString == strSelect[i])
{
CheckedListBox.Items[j].Selected;
}
}
}
foreach(object o in this.checkedListBox1.CheckedItems)
{
s+=o.ToString()+",";
//this.Text=s.Substring(0,s.Length-1);
}
for (int i=0;i<strSelect.Length;i++)
{
for(int j=0;j<CheckedListBox.Items.Count;j++)
{
if(CheckedListBox.Items[j].ToString == strSelect[i])
{
CheckedListBox.Items[j].Selected;
}
}
}这一个不对哦,没有Selected这个属性的。
checkedListBox1.ValueMember="intSectionID";
checkedListBox1.DisplayMember="txtShortDesc".ToString();for (int i = 0;i<checkedListBox1.CheckedItems.Count;i++)
{
DataRowView dv = ((System.Data.DataRowView)checkedListBox1.CheckedItems[i]);
aa+=dv["字段"].ToString()+";"
}