我有DataGridView
两列定义如下:
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)
我需要位置 Col=1, Row=0 的单元格是 aComboBox
而不是 a TextBox
。所以我尝试添加以下代码但它不起作用,编辑控件仍然是一个文本框。
Dim cbCell As New
DataGridViewComboBoxCell
cbCell.Items.AddRange([Enum].GetNames(GetType(System.Reflection.BindingFlags)))
S0Grid(1, 0) = cbCell
你知道我该如何解决这个问题吗?