I have a datagrid, and allowEdit has been disabled. I want to allow editing on a single record when a button is pushed.
How do I enable editing for a single record?
Implemented this by setting using the CellActivating and CellDeactivating events to control the AllowEdit setting on the field. Not sure if this is the best way to implement it.
private void OnCellActivating(object sender, CellActivatingEventArgs e) { if(e.Cell.Record.Tag != null && e.Cell.Record.Tag.ToString().CompareTo("CheckedOut") == 0) { e.Cell.Field.Settings.AllowEdit = true; } else if(e.Cell.Record.IsAddRecord) { e.Cell.Field.Settings.AllowEdit = true; } else { e.Cell.Field.Settings.AllowEdit = false; }}
private void OnCellDeactivating(object sender, CellDeactivatingEventArgs e){ e.Cell.Field.Settings.AllowEdit = false;}
The only problem is that when a cell has a drop down in it (XamComboEditor), if it's enabled, and I mouse over other fields in that column, it paints a drop down arrow. If I click on a another cell in that field that's not enabled, and then mouseover that cell, the down arrow is removed.
Hello,
Another way would be just to cancel (e.Cancel = true) the EditModeStarting event when the button is not pressed. You would not need to toggle the AllowEdit properties. Regarding the XamComboEditor's dropdown arrow, you can check out the DropDownButtonDisplayMode property of the XamComboEditor and set it to Always or OnlyInEditMode.