C#.NET SetComboBox Class


        public void SetComboBox(DataTable dt, ComboBox cbo)
        {
            cbo.DataSource = dt;
            cbo.DisplayMember = dt.Columns[0].ToString();
            cbo.ValueMember = dt.Columns[0].ToString();
            cbo.Text = "";
        }

        public void SetComboBox(DataTable dt, ComboBox cbo, int ColumnIndex)
        {
            cbo.Items.Clear();
            foreach (DataRow dr in dt.Rows)
            {
                cbo.Items.Add(dr[ColumnIndex - 1].ToString());
            }
        }

 

客户端应用:
            strSQL = "Select distinct Line from PAL_Routing_Line order by Line";
            dt = CESQL.GetDataTable(strSQL);
            CCMRule.SetComboBox(dt, cboLine);
            cboLine.Text = strLine;

            CESQLCCMRule类名

 

你可能感兴趣的:(combobox)