MVCxFormLayoutItemCollection<ModelType>.Add<ValueType>(Expression<Func<ModelType, ValueType>>, Action<MVCxFormLayoutItem>) Method
Adds a layout item to the MVCxFormLayoutItemCollection<ModelType> collection and specifies the item’s settings and a Model field to which the item is bound.
Namespace: DevExpress.Web.Mvc
Assembly: DevExpress.Web.Mvc5.v24.2.dll
Declaration
public MVCxFormLayoutItem Add<ValueType>(
Expression<Func<ModelType, ValueType>> expression,
Action<MVCxFormLayoutItem> method
)
Parameters
Name | Type | Description |
---|---|---|
expression | Expression<Func<ModelType, ValueType>> | An expression that identifies the object that contains the properties to edit or display. |
method | Action<MVCxFormLayoutItem> | A delegate method that accepts MVCxFormLayoutItem as a parameter. |
Type Parameters
Name |
---|
ValueType |
Returns
Type | Description |
---|---|
MVCxFormLayoutItem | An MVCxFormLayoutItem object that is the newly added layout item. |
Remarks
Use the Add<ValueType> method to add a customized layout item bound to the specified Model field.
Refer to the Binding to Data and Item Manipulation topics to learn more.
Example
The code sample below demonstrates how to add a customized layout item bound to the specified Model field to the FormLayout extension.
@Html.DevExpress().FormLayout(settings =>
{
settings.Name = "FormLayout1";
//Adding a bound to a Model field layout item with custom settings
settings.Items.Add(m => m.FirstName, i =>
{
// Defining the item's caption
i.Caption = "First Name";
// Defining the item's nested extension
i.NestedExtensionType = FormLayoutNestedExtensionItemType.TextBox;
// Defining the item's help text
i.HelpText = "Enter the First Name";
});
...
}).GetHtml()