Populate DataGridViewComboBoxColumn runtime
- by ghiboz
Hi all! I have this problem:
I have a datagridview that reads the data from a db and I wish, for an integer column use a combobox to choose some values...
I modified the column using DataGridViewComboBoxColumn type and after, on the init of the form this:
DataTable dt = new DataTable("dtControlType");
dt.Columns.Add("f_Id");
dt.Columns.Add("f_Desc");
dt.Rows.Add(0, "none");
dt.Rows.Add(1, "value 1");
dt.Rows.Add(2, "value 2");
dt.Rows.Add(3, "value 3");
pControlType.DataSource = dt;
pControlType.DataPropertyName = "pControlType";
pControlType.DisplayMember = "f_Desc";
pControlType.ValueMember = "f_Id";
but when the program starts (after this code) this message appears: