Back to Devexpress

TreeListView.CellEditorValueChanging Event

wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-3332a0ba.md

latest7.4 KB
Original Source

TreeListView.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

csharp
public event TreeListCellEditorValueChangingEventHandler CellEditorValueChanging
vb
Public Event CellEditorValueChanging As TreeListCellEditorValueChangingEventHandler

Event Data

The CellEditorValueChanging event's data class is TreeListCellEditorValueChangingEventArgs. The following properties provide information specific to this event:

PropertyDescription
CancelGets or sets whether the CellEditorValueChanging event is canceled.
CellGets a processed cell. Inherited from TreeListCellValueEventArgs.
ColumnGets a column that contains the edited cell. Inherited from TreeListCellValueEventArgs.
HandledGets 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.
NodeGets the processed node. Inherited from TreeListNodeEventArgs.
OldValueGets the cell’s previous value. Inherited from TreeListCellValueChangedEventArgs.
OriginalSourceGets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEventGets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
RowGets the processed row. Inherited from TreeListNodeEventArgs.
SourceGets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.
ValueGets or sets the processed cell’s value. Inherited from TreeListCellValueEventArgs.

The event data class exposes the following methods:

MethodDescription
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):

xaml
<ThemedWindow ...
    xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
    xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid">
    <Grid>
        <dxg:TreeListControl ItemsSource="{Binding DataItems}">
            <dxg:TreeListControl.Columns>
                <dxg:TreeListColumn FieldName="Name"/>
                <dxg:TreeListColumn FieldName="Executor"/>
                <dxg:TreeListColumn FieldName="State"/>
            </dxg:TreeListControl.Columns>
            <dxg:TreeListControl.View>
                <dxg:TreeListView  
                    TreeDerivationMode="ChildNodesSelector" 
                    ChildNodesPath="Tasks"
                    CellEditorValueChanging="OnStateCellEditorChanging"/>
            </dxg:TreeListControl.View>
        </dxg:TreeListControl>
    </Grid>
</ThemedWindow>
csharp
void OnStateCellEditorChanging(object sender, TreeListCellEditorValueChangingEventArgs e) {
    if (e.Column.FieldName == "State") {
        var result = MessageBox.Show(
            "Would you like to change the State value?",
            "Warning",
            MessageBoxButton.OKCancel,
            MessageBoxImage.Question,
            MessageBoxResult.OK
        );
        e.Cancel = (result == MessageBoxResult.Cancel);
    }
}

See Also

TreeListView Class

TreeListView Members

DevExpress.Xpf.Grid Namespace