• CheckedListBox与下拉框联动代码




    private void yewubind(string id) { //给业务类型下拉框绑定业务类型数据 DataTable dtyewu = sb.SelectLast(id, 0); bool flag = false; foreach (Control con in panel1.Controls) { if (con.Name == id) { con.Visible = true; flag = true; if (dtyewu.Rows.Count > 0) { } else { ((CheckedListBox)con).DataSource = null; } } else { con.Visible = false; } } if (!flag) { CheckedListBox clb_yewu = new CheckedListBox(); clb_yewu.Name = id; clb_yewu.Visible = true; if (dtyewu.Rows.Count > 0) { clb_yewu.DataSource = dtyewu; clb_yewu.DisplayMember = "name"; clb_yewu.ValueMember = "id"; } Size ss = new Size(200, 100); clb_yewu.Size = ss; panel1.Controls.Add(clb_yewu); } } private void cbb_jrh_SelectedIndexChanged(object sender, EventArgs e) { yewubind(cbb_jrh.SelectedValue.ToString()); }

    combobox联动 

                DataTable dtjrh = sb.SelectSyscode(2, true);
                if (dtjrh.Rows.Count > 0)
                {
                    cbb_jrh.DataSource = dtjrh;
                    cbb_jrh.DisplayMember = "name";
                    cbb_jrh.ValueMember = "id";
                    this.cbb_jrh.SelectedIndex = 0;
                }
                yewubind(cbb_jrh.SelectedValue.ToString());
    

      

    获取选中项 

       foreach (Control c in panel1.Controls)
                    {
                        foreach (DataRowView dr in ((CheckedListBox)c).CheckedItems)
                        {
                            yewuid += dr["id"].ToString() + ";";
                        }
                    }
    

      最后清空

     panel1.Controls.Clear();
       this.cbb_jrh.SelectedIndex = 0;
    

      

  • 相关阅读:
    Js~数组的操作push,pop,shift,unshift
    SqlServer 字段类型详解
    数据库设计三大范式
    HTML 解析类库HtmlAgilityPack
    设计模式六大原则
    表达式目录树
    在Web.config或App.config中的添加自定义配置
    史上最全 ——LINQ to SQL语句
    C# 加密解密类
    WebService登陆验证四种方式
  • 原文地址:https://www.cnblogs.com/paidaxing/p/3822005.html
Copyright © 2020-2023  润新知