windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-7a3ce509.md
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
public event CellValueChangedEventHandler CellValueChanged
Public Event CellValueChanged As CellValueChangedEventHandler
The CellValueChanged event's data class is CellValueChangedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| CellIndex | Gets the processed cell’s index. Inherited from RowCellEventArgs. |
| RecordIndex | Gets the index of the record containing the processed cell. Inherited from RowCellEventArgs. |
| Row | Gets the processed row. Inherited from RowEventArgs. |
| Value | Gets the current cell’s value. |
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:
The event doesn’t fire when a cell’s value is changed using the methods provided by the data source.
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.
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;
}
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