Back to Devexpress

CellValueChangedEventArgs.Value Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-cellvaluechangedeventargs-f055a0fd.md

latest4.6 KB
Original Source

CellValueChangedEventArgs.Value Property

Gets the current cell value.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
public object Value { get; }
vb
Public ReadOnly Property Value As Object

Property Value

TypeDescription
Object

An object representing the current cell value.

|

Remarks

If handling the ColumnView.CellValueChanging event, the Value property represents the active editor’s value. Note that this value can be later discarded by end-users or changed further. When handling the ColumnView.CellValueChanged event, the property returns the newly assigned cell value.

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Value property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-multi-cell-editing/CS/MultiSelectionEditingHelper.cs#L52

csharp
lockEvents = true;
SetSelectedCellsValues(e.Value);
lockEvents = false;

winforms-grid-multi-cell-editing/VB/MultiSelectionEditingHelper.vb#L46

vb
lockEvents = True
SetSelectedCellsValues(e.Value)
lockEvents = False

See Also

OldValue

RowHandle

Column

CellValueChangedEventArgs Class

CellValueChangedEventArgs Members

DevExpress.XtraGrid.Views.Base Namespace