zoukankan      html  css  js  c++  java
  • 选中CheckBoxList的值放到TextBox中,再次选中从textBox中删除

    当选中checkboxlist中的值,直接放到文本框中,在checkboxlist的SelectedIndexChanged事件下执行方法,

          //将选中的值放到文本框中
                    for (int i = 0; i < cblSupport.Items.Count; i++)
                    {
                        if (cblSupport.Items[i].Selected)
                        {
                            //如果文本框中不存在选中的内容,则在文本框中添加选中内容
                            if (txtSupport.Text.IndexOf(cblSupport.Items[i].Text) < 0)
                            {
                                this.txtSupport.Text += "," + cblSupport.Items[i].Text + ",";//可提供的支持
                            }
                            else
                            {//如果文本框中存在选中的内容,则在文本框中去掉选中内容
                                this.txtSupport.Text = this.txtSupport.Text.Replace(cblSupport.Items[i].Text , "");//可提供的支持
                            }
                        }
                    }
                    this.txtSupport.Text = this.txtSupport.Text.TrimStart(',');//去掉第一个逗号
                    this.txtSupport.Text = this.txtSupport.Text.TrimEnd(',');//去掉最后一个逗号
                    //将值放入文本框成功后,取消勾选,以防重复添加
                    for (int i = 0; i < cblSupport.Items.Count; i++)
                    {
                        if (cblSupport.Items[i].Selected)
                        {
                            this.cblSupport.Items[i].Selected = false;
                        }
                    }

  • 相关阅读:
    线性代数学习笔记
    机器学习基石笔记
    how to design Programs 学习笔记
    programming-languages学习笔记--第2部分
    P6859 蝴蝶与花 思维 + 数据结构优化
    P6429 [COCI2010-2011#6] STEP 线段树维护最长01
    P1637 三元上升子序列 树状数组优化DP
    线段树模板3.0 区间乘
    CodeForces Global Round 11 B. Chess Cheater 贪心,处理技巧
    CodeForces Global Round 11 A. Avoiding Zero 构造
  • 原文地址:https://www.cnblogs.com/SnailWalk/p/snailwalkwenxiao.html
Copyright © 2011-2022 走看看