求用c#编一个程序把CheckedListBox上选到的选项的内容输出到一个label上

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了求用c#编一个程序把CheckedListBox上选到的选项的内容输出到一个label上相关的知识,希望对你有一定的参考价值。

//checkedListBox1选项改变事件

        private void checkedListBox1_SelectedIndexChanged(object sender, 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上显示

           


       

效果展示:

参考技术A 用foreach

以上是关于求用c#编一个程序把CheckedListBox上选到的选项的内容输出到一个label上的主要内容,如果未能解决你的问题,请参考以下文章