Skip to main content

EditFormUserControl Class

A custom edit form for the Data Grid control.

Namespace: DevExpress.XtraGrid.Views.Grid

Assembly: DevExpress.XtraGrid.v24.2.dll

Declaration

public class EditFormUserControl :
    XtraUserControl,
    IExtenderProvider,
    IEditorFormTagProvider

Remarks

The EditFormUserControl binds its editors to data fields in the grid. For this purpose, the EditFormUserControl provides the following extender properties for the contained editors:

  • the BoundFieldName property specifies the field name in the underlying data source to which the editor is bound;
  • the BoundPropertyName property specifies the editor’s property to which a field value is assigned on initializing the Edit Form, and from which a value is fetched and posted back to the grid on saving data.

If an editor is contained on a EditFormUserControl descendant, you can specify the extender properties in Designer using the Properties window as shown below.

EditForm_CustomEditForm_BoundFieldName

In code, you can get and set the extender properties using the following methods:

The code snippet below shows a sample Edit Form.

using DevExpress.XtraGrid.Views.Grid;

class MyEditForm : EditFormUserControl {
    private DevExpress.XtraEditors.TextEdit textEdit1;
    public MyEditForm() {
        this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
        this.textEdit1.Location = new System.Drawing.Point(0, 0);
        this.textEdit1.Size = new System.Drawing.Size(100, 22);

        this.SetBoundFieldName(this.textEdit1, "Price");
        this.SetBoundPropertyName(this.textEdit1, "EditValue");
        this.Controls.Add(this.textEdit1);
        this.Size = new System.Drawing.Size(400, 200);
    }
}
//...
gridView1.OptionsBehavior.EditingMode = GridEditingMode.EditForm;
gridView1.OptionsEditForm.CustomEditFormLayout = new MyEditForm();

The created custom Edit Form should be assigned to the GridOptionsEditForm.CustomEditFormLayout property.

See the Modify and Validate Cell Values topic to learn more about how to edit and validate data in the grid.

See Also