windowsforms-devexpress-dot-xtratreelist-dot-treelist-7f222dee.md
Fires immediately after a user closes a cell editor with a modified value.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
[DXCategory("Property Changed")]
public event CellValueChangedEventHandler CellValueChanged
<DXCategory("Property Changed")>
Public Event CellValueChanged As CellValueChangedEventHandler
The CellValueChanged event's data class is CellValueChangedEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| ChangedByUser | Gets whether the user changed the value in an editor, or the value is changed in code. |
| Column | Gets a column to which the cell processed by an event belongs. Inherited from CellEventArgs. |
| Node | Gets the current Tree List node. Inherited from NodeEventArgs. |
| OldValue | |
| Value | Gets the new value assigned to a cell. |
Users need to activate an in-place editor in order to edit cell content. To do this, they need to click a cell or press the Enter/F2/Space key when a cell is focused. A click outside the edited cell, or the Tab/Enter key press, closes the editor. If the closed editor’s value has been modified, the CellValueChanged event occurs.
The CellValueChanged event fires when:
a user has changed the in-place editor value, and closes this editor;
a cell value was changed in code, for instance with the SetValue method (except for cases when this method is called in the event handler itself, or inside the BeginUnboundLoad/EndUnboundLoad block).
The code sample below illustrates how to update the “salesTax” column value when the “productPrice” column value changes.
treeList1.CellValueChanged += TreeList1_CellValueChanged;
private void TreeList1_CellValueChanged(object sender, DevExpress.XtraTreeList.CellValueChangedEventArgs e)
{
if (e.Column.FieldName == "productPrice")
{
TreeList list = sender as TreeList;
for (int i = 0; i < list.AllNodesCount; i++)
{
decimal price = 0.0M;
if (decimal.TryParse(e.Value.ToString(), out price))
list.SetRowCellValue(e.Node, "salesTax", price * 0.06M);
}
}
}
Private treeList1.CellValueChanged += AddressOf TreeList1_CellValueChanged
Private Sub TreeList1_CellValueChanged(ByVal sender As Object, ByVal e As DevExpress.XtraTreeList.CellValueChangedEventArgs)
If e.Column.FieldName = "productPrice" Then
Dim list As TreeList = TryCast(sender, TreeList)
For i As Integer = 0 To list.AllNodesCount - 1
Dim price As Decimal = 0.0D
If Decimal.TryParse(e.Value.ToString(), price) Then
list.SetRowCellValue(e.Node, "salesTax", price * 0.06D)
End If
Next i
End If
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the CellValueChanged event.
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.
private void SubscribeToControlEvents(TreeList treeList) {
treeList.CellValueChanged += treeList_CellValueChanged;
treeList.ShownEditor += treeList_ShownEditor;
See Also