Back to Devexpress

GridViewBase.CellValueChangedCommand Property

wpf-devexpress-dot-xpf-dot-grid-dot-gridviewbase-fa27a1d8.md

latest3.2 KB
Original Source

GridViewBase.CellValueChangedCommand Property

Gets or sets a command executed when a cell value is changed.

Namespace : DevExpress.Xpf.Grid

Assembly : DevExpress.Xpf.Grid.v25.2.dll

NuGet Package : DevExpress.Wpf.Grid.Core

Declaration

csharp
public ICommand<CellValueChangedArgs> CellValueChangedCommand { get; set; }
vb
Public Property CellValueChangedCommand As ICommand(Of CellValueChangedArgs)

Property Value

TypeDescription
ICommand<CellValueChangedArgs>

A command executed when a cell value is changed.

|

Remarks

Bind a command to the CellValueChangedCommand property to maintain a clean MVVM pattern. The command works like a CellValueChanged event handler and allows you to process cell value changes in a View Model.

The View executes the command in the following cases:

  • A user changes a cell value and closes the in-place editor.
  • You use the GridControl.SetCellValue method to change a cell value in code.

The following code sample changes the Order Priority based on the Order Type ‘s new value:

xaml
<dxg:GridControl ...>
    <dxg:GridColumn FieldName="OrderType"/>
    <dxg:GridColumn FieldName="OrderPriority"/>
    <dxg:GridControl.View>
        <dxg:TableView CellValueChangedCommand="{Binding CellValueChangedCommand}"/>
    </dxg:GridControl.View>
</dxg:GridControl>
csharp
[Command]
public void CellValueChanged(CellValueChangedArgs args) {
    if (args.FieldName == "OrderType")
        ((Order)args.Item).OrderPriority = priorities[(int)args.Value];
}
vb
<Command>
Public Sub CellValueChanged(ByVal args As CellValueChangedArgs)
    If args.FieldName = "OrderType" Then (CType(args.Item, Order)).OrderPriority = priorities(CInt(args.Value))
End Sub

The GridControl does not call a command bound to CellValueChangedCommand when you change a cell value in a data source.

Refer to the following topic for more information: Obtain and Set Cell Values.

See Also

CellValueChangingCommand

Immediate Posting

GridViewBase Class

GridViewBase Members

DevExpress.Xpf.Grid Namespace