Showing and Hiding Editors

  • 2 minutes to read

Showing and Hiding Editors

The focused cell's editor can be invoked by calling the TreeList.ShowEditor method. So, if you want to edit a specific cell, you must first focus it. If you want to close the editor programmatically, there are two methods available:

You can also use the Tree List's TreeList.PostEditor method to save changes without closing the editor.

The Tree List control also enables you to perform actions each time an editor is activated or closed, either by end-users or programmatically. This can be done by handling the TreeList.ShownEditor and TreeList.HiddenEditor events, respectively. The first one can be used to facilitate working with the editor itself (for example, you can open the MemoExEdit editor's popup window when it's activated). As for the TreeList.HiddenEditor event, you can handle it to perform any cleanup necessary after the TreeList.ShowEditor event handler has been executed, or to perform other actions when an editor is closed.

Note that the editors cannot be invoked in the following cases:

Example

The following example shows how to change the focused node's state image when an in-place editor is activated and closed. To respond to activating and closing in-place editors, the TreeList.ShownEditor and TreeList.HiddenEditor events are handled. The TreeList.CellValueChanged event is handled to change the node's select image, in order to indicate that the value of the node's cell has been modified by an end-user.

The image below shows the result.

cdShowingHidingEditors

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;
}