求用c#编一个程序把CheckedListBox上选到的选项的内容输出到一个label上来自
//che360问答ckedListBox1选项改变事件
private void checkedL整istBox1_SelectedIndexChanged(object send几止又兰目践赶办例龙析er, EventArgs e)
string str = "";
for (int i = 0; i < checkedListBox1.CheckedItems.Count; i++) //遍历checkedListBox1中选中的选项
str += checkedListBox1.CheckedItems[i].ToString() + "--"; //赋值到string
if (str.Length > 0) //判断str是否已赋值
label7.Text = str.Substring(0, (激省促那针察很及套促str.Length) - 2);//在label上显示
效果展示:
爱资源吧版权声明:以上文中内容来自网络,如有侵权请联系删除,谢谢。