I have a DataGridView
with two columns defined like:
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)
I need that the cell in position Col=1, Row=0 is a ComboBox
and not a TextBox
. So I tried to add the following code but it does not work, the edit control remains a TextBox.
Dim cbCell As New
DataGridViewComboBoxCell
cbCell.Items.AddRange([Enum].GetNames(GetType(System.Reflection.BindingFlags)))
S0Grid(1, 0) = cbCell
Do you know how can I solve this issue?
That code should work, is it possible that it's not getting called or that it throws or similar?
Try this code:
Dim cbCell As New DataGridViewComboBoxCell
S0Grid(1, 0) = cbCell
MessageBox.Show("Test")
Do you see the messagebox? And do you see the combo now?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.