Skip to main content
A newer version of this page is available. .

How to: Set a Cell Value When Another Column Value is Changed

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

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);
}