Back to Devexpress

EditFormUserControl Class

windowsforms-devexpress-dot-xtratreelist-3b61f92e.md

latest5.9 KB
Original Source

EditFormUserControl Class

Represents a custom Edit Form in the Tree List.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

csharp
public class EditFormUserControl :
    XtraUserControl,
    IExtenderProvider,
    IEditorFormTagProvider
vb
Public Class EditFormUserControl
    Inherits XtraUserControl
    Implements 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.

  • 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.

Example

The code below creates a custom Edit Form.

csharp
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;
vb
Imports DevExpress.XtraEditors
Imports DevExpress.XtraTreeList

treeList.OptionsBehavior.EditingMode = TreeListEditingMode.EditForm
' Create a custom EditForm
Dim control = New EditFormUserControl()
control.Height = treeList.Height \ 2
' Add editors
Dim memoEditNotes As New MemoEdit()
memoEditNotes.Dock = DockStyle.Fill
Dim textEditName As New TextEdit()
textEditName.Dock = DockStyle.Top
Dim textEditType As New TextEdit()
textEditType.Dock = DockStyle.Top
Dim dateEditDate As 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.

Implements

IXtraResizableControl

Inheritance

Object MarshalByRefObject Component Control ScrollableControl ContainerControl UserControl XtraUserControl EditFormUserControl

See Also

EditFormUserControl Members

DevExpress.XtraTreeList Namespace