Back to Devexpress

EditFormUserControl.GetBoundPropertyName(Control) Method

windowsforms-devexpress-dot-xtratreelist-dot-editformusercontrol-dot-getboundpropertyname-x28-system-dot-windows-dot-forms-dot-control-x29.md

latest5.3 KB
Original Source

EditFormUserControl.GetBoundPropertyName(Control) Method

Gets the editor’s property bound to the field in the data source.

Namespace : DevExpress.XtraTreeList

Assembly : DevExpress.XtraTreeList.v25.2.dll

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

Declaration

csharp
[DefaultValue("Text")]
public string GetBoundPropertyName(
    Control c
)
vb
<DefaultValue("Text")>
Public Function GetBoundPropertyName(
    c As Control
) As String

Parameters

NameTypeDescription
cControl

An object that specifies an editor on the Edit Form.

|

Returns

TypeDefaultDescription
String"Text"

The editor’s property bound to the field in the data source.

|

Remarks

The EditFormUserControl class implements the IExtenderProvider interface. The GetBoundPropertyName method supports the ProvideProperty attribute.

Use the SetBoundFieldName method to bind an editor on the Edit Form to a data source field. Use the SetBoundPropertyName method to set the editor’s property that is bound to the data source field. If the property name is not specified, the data source field is bound to the Control.Text or 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.

See Also

EditFormUserControl Class

EditFormUserControl Members

DevExpress.XtraTreeList Namespace