如何把checkedlistbox中每一个复选的项用空格隔开存到stirng里

解决方案 »

  1.   

    StringBuilder tempString = new StringBuilder();
    for(int i=cbl.SelectedIndex;i<cbl.Items.Count;i++)
    {
         if(cbl.Item[i].Selected)
         {
         tempString.Append(cbl.Item{i].Value);//还是要Text?
         tempString.Append(" ");
         }
    }return tempString.ToString().Trim();
      

  2.   

        for (int i = 0; i < checkedListBox1.Items.Count; i++ )
        {
    //如果这一项被选中
            if (checkedListBox1.GetItemChecked(i) == true)
            {
                MessageBox.Show(checkedListBox1.Items[i].ToString());
            }
        }
      

  3.   


       private void button1_Click(object sender, EventArgs e)
            {
                string msg = "";
                foreach (string str in this.checkedListBox1.CheckedItems) 
                {
                    msg += str + ",";//用“,”号隔开  累加成字符串
                }
                if (msg == "")
                    MessageBox.Show("no box is checked!");
                else
                {
                    msg += "are checked and" + this.checkedListBox1.SelectedItem.ToString() + "is selected";
                    MessageBox.Show(msg);
                }
            }
      

  4.   

    这个好像不对啊,我是想要把checkedlistbox里打勾的每一项的text用空格隔开存到string里
      

  5.   

    C# 实现 checkedListBox单选(多种方法)
      

  6.   

    谢谢,搞定了,帮忙看下另外的问题吧
    http://topic.csdn.net/u/20110415/14/b7882f60-15d2-435a-880e-c567ada0dc8a.html