views:

25

answers:

1

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?

A: 

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?

ho1
@ho1 thank you for the interest. I verified and the code is executed, maybe some other setting interfer with my implementation. I will do additional checks
marco.ragogna