TreeList.EditFormHidden Event
Fires after the Edit Form is closed.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v24.1.dll
NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList
Declaration
Event Data
The EditFormHidden event's data class is EditFormHiddenEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
BindableControls | Provides access to the collection of controls used to edit the processed data record. Controls are indexed by field names or tree list nodes. |
Node | Gets the node for which the Edit From is closed. |
Panel | Gets the Edit Form’s root panel. |
Result | Gets the clicked button. |
Examples
The control displays a list of booked flights. A user edits flights in the Edit Form. The code below shows how to do the following:
disable the Return field if the One Way option is selected
set the Return field’s minimum value to the Departure field’s value
using DevExpress.XtraEditors;
treeList1.OptionsBehavior.EditingMode = DevExpress.XtraTreeList.TreeListEditingMode.EditForm;
treeList1.EditFormPrepared += TreeList1_EditFormPrepared;
treeList1.EditFormHidden += TreeList1_EditFormHidden;
CheckEdit editOneWay;
DateEdit editDeparture;
DateEdit editReturn;
private void TreeList1_EditFormPrepared(object sender, DevExpress.XtraTreeList.EditFormPreparedEventArgs e) {
editDeparture = e.BindableControls["Departure"] as DateEdit;
editReturn = e.BindableControls["Return"] as DateEdit;
editOneWay = e.BindableControls["One Way"] as CheckEdit;
if (editOneWay != null)
editOneWay.EditValueChanging += EditOneWay_EditValueChanging;
if(editDeparture != null)
editDeparture.EditValueChanged += EditDeparture_EditValueChanged;
}
private void EditDeparture_EditValueChanged(object sender, EventArgs e) {
editReturn.Properties.MinValue = (DateTime)editDeparture.EditValue;
}
private void EditOneWay_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e) {
if ((bool)e.NewValue)
editReturn.Enabled = false;
else
editReturn.Enabled = true;
}
private void TreeList1_EditFormHidden(object sender, DevExpress.XtraTreeList.EditFormHiddenEventArgs e) {
if (editOneWay != null)
editOneWay.EditValueChanging -= EditOneWay_EditValueChanging;
if(editDeparture != null)
editDeparture.EditValueChanged -= EditDeparture_EditValueChanged;
editOneWay = null;
editDeparture = null;
editReturn = null;
}
The code below shows how to prevent the Edit Form from being shown in a particular case, focus an editor in the Edit Form, subscribe to the editor’s events, and get the clicked button when the Edit Form is closed.
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraTreeList;
// Prevents the Edit Form from being shown depending on the cell data.
private void treeList1_EditFormShowing(object sender, DevExpress.XtraTreeList.EditFormShowingEventArgs e) {
if (e.Node.GetValue(colCity).Equals("Berlin"))
e.Allow = false;
}
// Focuses the editor in the Edit Form that corresponds to the column focused in the Tree List.
// Subscribes to an editor's events.
private void treeList1_EditFormPrepared(object sender, DevExpress.XtraTreeList.EditFormPreparedEventArgs e) {
TreeList treeList = sender as TreeList;
Control editor = e.BindableControls[treeList.FocusedColumn];
if (editor != null) {
editor.Focus();
((IContainerControl)e.Panel).ActivateControl(editor);
}
TextEdit textEdit = e.BindableControls[colCity] as TextEdit;
if (textEdit != null)
textEdit.EditValueChanging += TextEdit_EditValueChanging;
}
private void TextEdit_EditValueChanging(object sender, ChangingEventArgs e) {
// ...
}
// Unsubscribes from the editor's events.
// Shows a message depending on the clicked button.
private void treeList1_EditFormHidden(object sender, DevExpress.XtraTreeList.EditFormHiddenEventArgs e) {
TextEdit textEdit = e.BindableControls[colCity] as TextEdit;
if (textEdit != null)
textEdit.EditValueChanging -= TextEdit_EditValueChanging;
if (e.Result == EditFormResult.Update)
XtraMessageBox.Show("Changes are successfully saved.");
}