Back to Devexpress

How to: Change a node's image when in-place editors are activated and closed

windowsforms-5638-controls-and-libraries-tree-list-examples-data-editing-how-to-change-a-nodes-image-when-in-place-editors-are-activated-and-closed.md

latest2.1 KB
Original Source

How to: Change a node's image when in-place editors are activated and closed

  • Aug 01, 2019

The example below handles the following events to change the focused node’s images:

  • TreeList.ShownEditor — sets the node’s state image to indicate that the node is being modified. This event fires when the editor is activated.
  • TreeList.HiddenEditor — removes the node’s state image. This event fires when the editor is deactivated.
  • TreeList.CellValueChanged — sets the node’s select image to indicate that the value has been modified.

csharp
using DevExpress.XtraTreeList;

private void treeList1_ShownEditor(object sender, System.EventArgs e) {
   TreeList tlist = sender as TreeList;
   tlist.FocusedNode.StateImageIndex = 0;
}

private void treeList1_HiddenEditor(object sender, System.EventArgs e) {
   TreeList tlist = sender as TreeList;
   tlist.FocusedNode.StateImageIndex = -1;
}

private void treeList1_CellValueChanged(object sender, 
DevExpress.XtraTreeList.CellValueChangedEventArgs e) {
   e.Node.SelectImageIndex = 1;
   e.Node.ImageIndex = 1;
}
vb
Imports DevExpress.XtraTreeList

Private Sub TreeList1_ShownEditor(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles TreeList1.ShownEditor
   Dim tlist As TreeList = CType(sender, TreeList)
   tlist.FocusedNode.StateImageIndex = 0
End Sub

Private Sub TreeList1_HiddenEditor(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles TreeList1.HiddenEditor
   Dim tlist As TreeList = CType(sender, TreeList)
   tlist.FocusedNode.StateImageIndex = -1
End Sub

Private Sub TreeList1_CellValueChanged(ByVal sender As Object, 
ByVal e As DevExpress.XtraTreeList.CellValueChangedEventArgs) 
Handles TreeList1.CellValueChanged
   e.Node.SelectImageIndex = 1
   e.Node.ImageIndex = 1
End Sub