如何在dataGridView1 中DataGridViewComboBoxColumn显示默认值?没有选择时,显示默认值
6 回答
慕雪6442864
TA贡献1812条经验 获得超5个赞
DataGridViewComboBoxColumn Column = new DataGridViewComboBoxColumn();
dataGridView1.Columns.Add(Column); Column.Items.Add("内容1"); Column.Items.Add("内容2"); Column.DefaultCellStyle.NullValue = "内容1"; 内容1就为显示的默认值。
青春有我
TA贡献1784条经验 获得超8个赞
List items = new List(); items.Add(new Items { Text = "A", Value = "a" }); items.Add(new Items { Text = "B", Value = "b" });
DataGridViewComboBoxColumn co = this.dataGridView1.Columns[0] as DataGridViewComboBoxColumn; co.DataSource = items; co.DisplayMember = "Text"; co.ValueMember = "Value";
this.dataGridView1.Rows.Add(new object[] { "a" }); this.dataGridView1.Rows.Add(new object[] { "b" });
- 6 回答
- 0 关注
- 924 浏览
添加回答
举报
0/150
提交
取消