0
我有两列的DataGridView
像定义:如何在DataGridView的TextBoxCell列中设置单个ComboBoxCell?
Dim col As New DataGridViewColumn
col.DefaultCellStyle.BackColor = Color.FromArgb(&HFFAAAAAA)
col.Name = "Description"
col.MinimumWidth = 80
col.DataPropertyName = "Description"
col.ValueType = GetType(String)
col.ReadOnly = True
col.CellTemplate = New DataGridViewTextBoxCell
S0Grid.Columns.Add(col)
col = New DataGridViewColumn
col.DefaultCellStyle.BackColor = Color.FromArgb(&HFFBBBBBB)
col.Name = "Value"
col.MinimumWidth = 80
col.DataPropertyName = "Value"
col.ValueType = GetType(String)
col.CellTemplate = New DataGridViewTextBoxCell
S0Grid.Columns.Add(col)
我需要在位置列= 1,行= 0的小区是ComboBox
,而不是一个TextBox
。所以我试图添加下面的代码,但它不起作用,编辑控件仍然是一个TextBox。
Dim cbCell As New
DataGridViewComboBoxCell
cbCell.Items.AddRange([Enum].GetNames(GetType(System.Reflection.BindingFlags)))
S0Grid(1, 0) = cbCell
你知道我该如何解决这个问题?
感谢您的关注。我验证并执行了代码,也许其他一些设置会干扰我的实现。我会做额外的检查 – Drake 2010-06-22 07:52:44