日期:2014-05-18 浏览次数:20964 次
string listSql = "select distinct MR_Name from MIS_MaterielRegiser"; OleDbCommand cmd = new OleDbCommand(listSql, ocnn); OleDbDataAdapter da = new OleDbDataAdapter(); DataSet set = new DataSet(); da.SelectCommand = cmd; da.Fill(set); // 手动添加下拉列,并绑定数据源 DataGridViewTextBoxColumn column1 = new DataGridViewTextBoxColumn(); column1.HeaderText = "货料编号"; column1.SortMode = DataGridViewColumnSortMode.NotSortable; this.dgv_InInfo.Columns.Add(column1); DataGridViewComboBoxColumn column2 = new DataGridViewComboBoxColumn(); column2.DataSource = set.Tables[0]; column2.DisplayMember = "MR_Name"; column2.HeaderText = "货料名称"; column2.SortMode = DataGridViewColumnSortMode.NotSortable; this.dgv_InInfo.Columns.Add(column2); string ModelSql = "select MR_Model from MIS_MaterielRegiser"; ocmd = new OleDbCommand(ModelSql,ocnn); oda = new OleDbDataAdapter(ocmd); DataSet data = new DataSet(); oda.Fill(data); DataGridViewComboBoxColumn column3 = new DataGridViewComboBoxColumn(); column3.HeaderText = "规格型号"; column3.SortMode = DataGridViewColumnSortMode.NotSortable; this.dgv_InInfo.Columns.Add(column3); column3.DataSource = data.Tables[0]; column3.DisplayMember = "MR_Model";
规格型号