• 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;
    

      

  • 相关阅读:
    python's is&==区别
    python's decorator&wrapper
    objects & values & types
    linux sort命令
    partial function
    proc文件系统
    readlink 获取当前进程对应proc/self/exe
    Workgroup&Domain(Realm)
    python传值&值引用
    Unpacking Argument Lists
  • 原文地址:https://www.cnblogs.com/paidaxing/p/3822005.html
Copyright © 2020-2023  润新知