windowsforms-5637-controls-and-libraries-tree-list-feature-center-data-editing-showing-and-hiding-editors.md
Users can edit data in the focused cell. To activate the focused cell’s editor, users can press Enter, F2, or click the cell. The EditorShowMode option specifies how an editor is activated on a mouse click:
Note
If the Ctrl, Alt, or Shift key is pressed, the clicked cell is focused, but its editor is not activated.
Use the following methods to activate and deactivate the focused cell’s editor:
Note
An editor cannot be activated in the following cases:
After an editor is activated, you can use the control’s ActiveEditor property to access it. If there is no active editor in the control, this property returns null ( Nothing in VB). To obtain or set the active editor’s value, use the EditingValue property.
The control raises the following events when a user activates an editor:
Use the following properties to determine the focused cell:
You can also use the editor’s ContainsFocus property to check if the editor is focused. For an editor that can display a pop-up window (for example, a date editor), you can use the EditorContainsFocus property, which returns whether the editor or its pop-up window is focused.
Edits in the focused node are posted to the bound data source only when the node loses focus. Prior to this, edits are stored in cell editors. You can call the following methods to forcibly post the edited node to the data source or discard the changes:
The code below posts the focused node’s values to the data source each time an editor is hidden.
private void treeList1_HiddenEditor(object sender, EventArgs e) {
TreeList treeList = sender as TreeList;
treeList.EndCurrentEdit();
}
Private Sub treeList1_HiddenEditor(ByVal sender As Object, ByVal e As EventArgs)
Dim treeList As TreeList = TryCast(sender, TreeList)
treeList.EndCurrentEdit()
End Sub
Use the OptionsNavigation property to access the following settings that allow you to specify how users can move focus:
The example below handles the following events to change the focused node’s images:
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;
}
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