Back to Devexpress

VGridControlBase.CellValueChanged Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-7a3ce509.md

latest4.5 KB
Original Source

VGridControlBase.CellValueChanged Event

Fires immediately after a cell’s value has been changed.

Namespace : DevExpress.XtraVerticalGrid

Assembly : DevExpress.XtraVerticalGrid.v25.2.dll

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

Declaration

csharp
public event CellValueChangedEventHandler CellValueChanged
vb
Public Event CellValueChanged As CellValueChangedEventHandler

Event Data

The CellValueChanged event's data class is CellValueChangedEventArgs. The following properties provide information specific to this event:

PropertyDescription
CellIndexGets the processed cell’s index. Inherited from RowCellEventArgs.
RecordIndexGets the index of the record containing the processed cell. Inherited from RowCellEventArgs.
RowGets the processed row. Inherited from RowEventArgs.
ValueGets the current cell’s value.

Remarks

The CellValueChanged event fires in response to a cell’s value being changed. The list below points out the possible reasons for this event being raised:

  • an end-user has closed an inplace editor after changing the edited cell’s value;
  • a cell’s value has been changed using the methods provided by the grid control (for instance, the VGridControlBase.SetCellValue method);

The event doesn’t fire when a cell’s value is changed using the methods provided by the data source.

Example

The following sample code handles the VGridControlBase.CellValueChanged event to change the processed row’s style if its summary data cells value is greater than 100,000. To get a cell’s value, the code uses the VGridControlBase.GetCellValue method.

csharp
using DevExpress.Utils;
using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Rows;
using DevExpress.XtraVerticalGrid.Events;

private void vGridControl1_CellValueChanged(object sender, CellValueChangedEventArgs e) {
   double sum = 0;
   for (int i = 0; i < vGridControl1.RecordCount; i++)
      sum += Convert.ToDouble(vGridControl1.GetCellValue(e.Row, i));
   if (sum > 100000)
      e.Row.Appearance.BackColor = Color.Red;
   else
      e.Row.Appearance.Options.UseBackColor = false;
}
vb
Imports DevExpress.Utils
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Rows
Imports DevExpress.XtraVerticalGrid.Events

Private Sub VGridControl1_CellValueChanged(ByVal sender As Object, _
ByVal e As CellValueChangedEventArgs) Handles VGridControl1.CellValueChanged
   Dim sum As Double = 0
   Dim i As Integer
   For i = 0 To i < VGridControl1.RecordCount
      sum = sum + Convert.ToDouble(VGridControl1.GetCellValue(e.Row, i))
   Next i
   If sum > 100000 Then
      e.Row.Appearance.BackColor = Color.Red
   Else
      e.Row.Appearance.Options.UseBackColor = False
   End If
End Sub

See Also

CellValueChanging

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace