Back to Devexpress

CellValueChangedEventArgs Class

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-6da8a7a1.md

latest4.3 KB
Original Source

CellValueChangedEventArgs Class

Provides data for the ColumnView.CellValueChanging and ColumnView.CellValueChanged events.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

NuGet Packages : DevExpress.Win.Grid, DevExpress.Win.Navigation

Declaration

csharp
public class CellValueChangedEventArgs :
    EventArgs
vb
Public Class CellValueChangedEventArgs
    Inherits EventArgs

CellValueChangedEventArgs is the data class for the following events:

Remarks

The ColumnView.CellValueChanging and ColumnView.CellValueChanged events fire in response to cell value modifications. Thus, CellValueChangedEventArgs class members allow you to identify the cell and obtain its current value. The processed cell is identified by the CellValueChangedEventArgs.RowHandle and CellValueChangedEventArgs.Column properties. The CellValueChangedEventArgs.Value property holds the newly assigned value.

CellValueChangedEventArgs objects with proper settings are automatically created and passed to ColumnView.CellValueChanging and ColumnView.CellValueChanged event handlers.

Example

The following sample code handles the ColumnView.CellValueChanged event to update the FullName column value after the FirstName column value has been changed.

csharp
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.BandedGrid;

private void bandedGridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) {
    BandedGridView view = sender as BandedGridView;
    if (view == null) return;
    if (e.Column.Caption != "FirstName") return;
    string cellValue = e.Value.ToString() + " " + view.GetRowCellValue(e.RowHandle, view.Columns["LastName"]).ToString();
    view.SetRowCellValue(e.RowHandle, view.Columns["FullName"], cellValue);
}
vb
Imports DevExpress.XtraGrid.Views.Base
Imports DevExpress.XtraGrid.Views.BandedGrid

Private Sub BandedGridView1_CellValueChanged(sender As Object, e As DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs) Handles BandedGridView1.CellValueChanged
    Dim view As BandedGridView = sender
    If view Is Nothing Then
        Return
    End If
    If e.Column.Caption <> "FirstName" Then
        Return
    End If
    Dim cellValue As String = e.Value.ToString() + " " + view.GetRowCellValue(e.RowHandle, view.Columns("LastName")).ToString()
    view.SetRowCellValue(e.RowHandle, view.Columns("FullName"), cellValue)
End Sub

Inheritance

Object EventArgs CellValueChangedEventArgs

See Also

CellValueChangedEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace