The following sample code handles the ColumnView.CellValueChanged event to update the FullName column value after the FirstName column value has been changed.
C#
using DevExpress.XtraGrid.Views.Base;
private void bandedGridView1_CellValueChanged(object sender, CellValueChangedEventArgs e) {
if (e.Column.Caption != "FirstName") return;
string cellValue = e.Value.ToString() + " " +
bandedGridView1.GetRowCellValue(e.RowHandle,
bandedGridView1.Columns["LastName"]).ToString();
bandedGridView1.SetRowCellValue(e.RowHandle,
bandedGridView1.Columns["FullName"], cellValue);
}
VB
Imports DevExpress.XtraGrid.Views.Base
Private Sub BandedGridView1_CellValueChanged(ByVal sender As Object, _
ByVal e As CellValueChangedEventArgs) Handles BandedGridView1.CellValueChanged
If e.Column.Caption <> "FirstName" Then Exit Sub
Dim cellValue As String = e.Value.ToString() + " " + _
BandedGridView1.GetRowCellValue(e.RowHandle, _
BandedGridView1.Columns("LastName")).ToString()
BandedGridView1.SetRowCellValue(e.RowHandle, _
BandedGridView1.Columns("FullName"), cellValue)
End Sub
No comments:
Post a Comment