日期:2014-05-18 浏览次数:20899 次
DataGridViewComboBoxColumn cbcm1 = new DataGridViewComboBoxColumn(); cbcm1.HeaderText = "测试"; cbcm1.Items.Clear(); string[] array = new string[ds.Tables[0].Rows.Count]; for (int i = 0; i < array.Length; i++) { array[i] = ds.Tables[0].Rows[i]["name"].ToString(); } cbcm1.Items.AddRange(array); cbcm1.DataPropertyName = "数据库语句字段名"; //美化 cbcm1.DisplayStyle = DataGridViewComboBoxDisplayStyle.ComboBox; cbcm1.DisplayStyleForCurrentCellOnly = true; gridProject.Columns.Insert(5, cbcm1);