GridViewBase.CellEditorValueChanging Event
Occurs when the cell editor value is changed and allows you to cancel changes.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v25.2.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Event Data
The CellEditorValueChanging event's data class is CellEditorValueChangingEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Cancel | Gets or sets whether the CellEditorValueChanging event is canceled. |
| Cell | Gets a processed cell. Inherited from CellValueEventArgs. |
| Column | Gets a column that contains the edited cell. Inherited from CellValueEventArgs. |
| Handled | Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs. |
| OldValue | Gets the cell’s previous value. Inherited from CellValueChangedEventArgs. |
| OriginalSource | Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs. |
| RoutedEvent | Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs. |
| Row | Gets the processed row. Inherited from RowEventArgs. |
| RowHandle | Gets the processed row’s handle. Inherited from RowEventArgs. |
| Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
| Value | Gets or sets the processed cell’s value. Inherited from CellValueEventArgs. |
The event data class exposes the following methods:
| Method | Description |
|---|---|
| InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
| OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
Remarks
The CellEditorValueChanging event is raised only when a user modifies a cell value using an in-place editor (a user types or deletes a character, chooses a value from a drop-down list, etc.). You cannot raise the event in code.
To restore the previous cell editor value (and prevent the CellValueChanging event from occurring), set the Cancel property to true.
Example
The following example prompts a user before changing a cell value (if the action is canceled, the cell value remains unchanged):
<ThemedWindow ...
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
<Grid>
<dxg:GridControl ...>
<dxg:GridControl.View>
<dxg:TableView ...
CellEditorValueChanging="OnIsActiveCellEditorChanging"/>
</dxg:GridControl.View>
</dxg:GridControl>
</Grid>
</ThemedWindow>
void OnIsActiveCellEditorChanging(object sender, CellEditorValueChangingEventArgs e) {
if (e.Column.FieldName == "IsActive") {
var result = MessageBox.Show(
"Would you like to change the Active status?",
"Warning",
MessageBoxButton.OKCancel,
MessageBoxImage.Question,
MessageBoxResult.OK
);
e.Cancel = (result == MessageBoxResult.Cancel);
}
}