关于ComboBox的运用

来源:互联网 发布:淘宝店铺 售假 申诉 编辑:程序博客网 时间:2024/05/16 01:38

清楚原有项目,然后更新ComboBox:

            ComboBox1.Items.Clear();


            DataTable dt = new DataTable();
            dt = PubClass.Executesql_Select("select classname from class_v2 where scid='" + scid + "'");

            if (dt.Rows.Count > 0) {
                int i;
                for (i = 0; i < dt.Rows.Count; i++) {
                    ComboBox1.Items.Add(dt.Rows[i][0]);
                }
            }


简单的ComboBox 的运用:

            DataTable dt = PubClass.Executesql_Select("select classname from class_v2 where scid='"+scid+"'");
            string[] array = new string[dt.Rows.Count];
            for (int i = 0; i < dt.Rows.Count; i++) {
                array[i] = dt.Rows[i][0].ToString();
            }
            bj.DataSource = array;

原创粉丝点击