Hello,
I’m finding some troubles with editing multiple selected rows of an Eto GridView in one go.
The setup
I’m using a binding with a proper data model, like so:
internal class DataModel : INotifyPropertyChanged
{
private string m_myProperty;
public event PropertyChangedEventHandler PropertyChanged;
public string MyProperty
{
get {
return m_myProperty;
}
set {
m_size = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(MyProperty)));
}
}
public DataModel(string value)
{
m_myProperty = value;
}
}
I’m creating a column with
m_dataGrid.Columns.Add(new GridColumn() {
DataCell = new TextBoxCell("MyProperty"),
HeaderText = I18n.Tr("MyProperty"),
Editable = true,
Resizable = false,
Sortable = false,
AutoSize = true
});
and finally setting the m_dataGrid.DataStore
with an ObservableCollection<DataModel>
object.
What I want to achieve
When multiple rows are selected, I want to change a cell value and apply the same value to all other selected cells.
I tried to subscribe the GridView’s OnCellEdited
, obtaining the modified value and setting the same value on the DataStored items corresponding to the selected rows indices, but the change is not reflected in the grid.
I thought a ReloadData()
method should be invoked on the GridView, but invoking that inside the OnCellEdited
method raises an exception (Refresh not allowed during an AddNew or EditItem transaction), which basically states that (despite the OnCellEditED method name suggests), the editing is not finished yet.
Maybe there is a simpler and smarter solution that I don’t see, to achieve the same result.
Any suggestions?