private void mapControlToCommandGrid_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
var Cell = mapControlToCommandGrid.Rows[e.RowIndex].Cells[e.ColumnIndex];
var Row = Cell.OwningRow;
var Col = Cell.OwningColumn;
if (Col.IsDataBound && Col.Name == "CatCmdIdColumn")
{
if (mapControlToCommandGrid.CurrentCell.EditType == typeof(DataGridViewComboBoxEditingControl))
{
DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)mapControlToCommandGrid[e.ColumnIndex, e.RowIndex];
cb.DataSource = catCmdsBindingSource;
}
}
else if (Col.IsDataBound && Col.Name == "midiControlTypeColumn")
{
ControlType ctrlType = (ControlType)Row.Cells["midiControlTypeColumn"].Value;
CatCmd CatCmdValue = (CatCmd)Row.Cells["CatCmdIdColumn"].Value;
var attr = CatCmdDb.Get(CatCmdValue);
if (attr.ControlType != ctrlType)
{
System.Data.DataRowView obj = (System.Data.DataRowView)mapControlToCommandGrid.CurrentRow.DataBoundItem;
obj.BeginEdit();
obj.Row["CatCmdId"] = 0;
obj.EndEdit();
}
}
}