I have DataGridView with DataGridViewComboBoxColumn with datasource binding, when I bind DataPropertyName of DataGridView, ComboBox becomes not clickable.
dgFMS.ReadOnly = false;
Correct DataPropertyName is bind with each row but I can not choose from drop-down
BindingSource _bsCats2 = new BindingSource();
DataGridViewComboBoxColumn catCol = new DataGridViewComboBoxColumn();
_bsCats2.DataSource = CategoryManager.Categories.Select(x => new {
Key = x.ParentWithName.ToLowerInvariant(),
Value = x.Id })
.ToList();
catCol.DataSource = _bsCats2;
catCol.DataPropertyName = "catID";
catCol.DisplayMember = "Key";
catCol.ValueMember = "Value";
catCol.Width = 250;
catCol.ReadOnly = false;
dgFMS.Columns.Add(catCol);
dgFMS.ReadOnly = false;
I am also implementing dgFMS_EditingControlShowing as well
private void dgFMS_EditingControlShowing(object sender,
DataGridViewEditingControlShowingEventArgs e)
{
ComboBox cb = e.Control as ComboBox;
if (cb != null)
{
cb.DropDownStyle = ComboBoxStyle.DropDown;
cb.SelectedValueChanged -= new EventHandler(CmbCat_SelectedIndexChanged);
cb.SelectedValueChanged += new EventHandler(CmbCat_SelectedIndexChanged);
}
}