日期:2014-05-18 浏览次数:20508 次
DataTable data = new DataTable(); data.Columns.Add("column1", typeof(int)); data.Columns.Add("column2", typeof(string)); DataRow dr1 = data.NewRow(); dr1["column1"] = 1; dr1["column2"] = "NO.1"; DataRow dr2 = data.NewRow(); dr2["column1"] = 2; dr2["column2"] = "NO.2"; DataRow dr3 = data.NewRow(); dr3["column1"] = 3; dr3["column2"] = "NO.3"; DataRow dr4 = data.NewRow(); data.Rows.Add(dr1); data.Rows.Add(dr2); data.Rows.Add(dr3); this.comboBox1.DataSource = data; this.comboBox1.DisplayMember = "column2"; this.comboBox1.ValueMember = "column2";