EditFormUserControl Class
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v24.2.dll
Declaration
public class EditFormUserControl :
XtraUserControl,
IExtenderProvider,
IEditorFormTagProvider
Remarks
You can allow users to edit cell values in the Edit Form instead of In-place Editors. The Tree List automatically creates a default Edit Form based on data fields. You can also use a custom user control instead of the default Edit Form.
Follow the steps below to display a custom user control instead of the default Edit Form:
- use the
EditFormUserControl
class as a base class for a custom Edit Form; - place editors onto the created Edit Form;
- bind editors to data fields (see below);
- assign the created Edit Form to the CustomEditFormLayout property.
The EditFormUserControl
is an IExtenderProvider. To bind editors to data fields, use the following extender properties allocated to editors by the EditFormUserControl
:
FieldName
— gets or sets the name of the data field that is bound to the editor.In code, you can use the GetBoundFieldName(Control) and SetBoundFieldName(Control, String) methods to specify the bound data field.
PropertyName
— gets or sets the name of the property that specifies the editor value. Default properties are the Control.Text and BaseEdit.EditValue property depending on the editor type.In code, you can use the GetBoundPropertyName(Control) and SetBoundPropertyName(Control, String) methods to specify the bound property.
Example
The code below creates a custom Edit Form.
using DevExpress.XtraEditors;
using DevExpress.XtraTreeList;
treeList.OptionsBehavior.EditingMode = TreeListEditingMode.EditForm;
// Create a custom EditForm
var control = new EditFormUserControl();
control.Height = treeList.Height / 2;
// Add editors
MemoEdit memoEditNotes = new MemoEdit();
memoEditNotes.Dock = DockStyle.Fill;
TextEdit textEditName = new TextEdit();
textEditName.Dock = DockStyle.Top;
TextEdit textEditType = new TextEdit();
textEditType.Dock = DockStyle.Top;
DateEdit dateEditDate = new DateEdit();
dateEditDate.Dock = DockStyle.Bottom;
control.Controls.Add(memoEditNotes);
control.Controls.Add(dateEditDate);
control.Controls.Add(textEditType);
control.Controls.Add(textEditName);
// Bind the editors to data source fields
control.SetBoundFieldName(memoEditNotes, "Notes");
control.SetBoundFieldName(textEditName, "Name");
control.SetBoundFieldName(textEditType, "TypeOfObject");
control.SetBoundFieldName(dateEditDate, "RecordDate");
// Assign the Edit Form to the Tree List
treeList.OptionsEditForm.CustomEditFormLayout = control;
Note
Run the following demo for the complete example: Edit nodes with a custom Edit Form.