コード例 #1
0
 //设置combox的值--------------
 private void setCombo(string sql, CheckedComboBox cmb)
 {
     //清空下拉列表
     cmb.Items.Clear();
     //cmb.Items.Add("%");
     //cmb.Text = "%";
     //实例化一个类
     getLxerpConn v = new getLxerpConn();
     //获取类里面的sql连接到数据库的字符串
     v.getsqlconn();
     //  string connStr = "Data Source=.\\sql2008;Initial Catalog=books;Integrated Security=True"; //连接到数据库的字符串
     SqlConnection cn = new SqlConnection(v.Sqlconn);
     //打开链接
     cn.Open();
     SqlCommand cmd = cn.CreateCommand();
     cmd.CommandText = sql;
     SqlDataReader dr = cmd.ExecuteReader();
     while (dr.Read())
     {
         cmb.Items.Add(dr.GetValue(0).ToString().Trim());
     }
     cn.Close();
     cn.Dispose();
 }
コード例 #2
0
        private CheckedComboBox Add_CheckedComboBox(CheckedComboBox ccb, Control above_crl, string sql, string lableText)
        {
            ccb = new CheckedComboBox();
            setCombo(sql, ccb);
            ccb.Top = above_crl.Top + above_crl.Height + 13;
            ccb.Left = above_crl.Left;
            groupPanel2.Controls.Add(ccb);

            Label l = new Label();
            l.Text = lableText;
            l.Top = above_crl.Top + above_crl.Height + 16;
            l.Left = label1.Left;
            l.BackColor = Color.Transparent;
            groupPanel2.Controls.Add(l);

            return ccb;
        }
コード例 #3
0
            // ********************************************* Construction *********************************************

            public Dropdown(CheckedComboBox ccbParent)
            {
                this.ccbParent = ccbParent;
                InitializeComponent();
                this.ShowInTaskbar = false;
                // Add a handler to notify our parent of ItemCheck events.
                this.cclb.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.cclb_ItemCheck);
            }