Assigning Editors to Editor Rows

  • 3 minutes to read

This topic describes how to bind editors to editor rows. This editor binding approach is frequently used since editor rows represent data fields that typically contain values of the same type - so it is natural to use the same editor for all cells in a row. Multi-editor rows can display data from several bound data fields, so you can bind multiple editors to a multi-editor row. For more information, see the Assigning Editors to Multi-Editor Rows topic. The In-place Editors topic describes the repository mechanism used to implement in-place editing functionality.

Assign Editors at Design Time

To specify a row's in-place editor, create a specific repository item and add it to the vertical grid's internal or external repository. Then, assign it to a row via the RowProperties.RowEdit property.

At design time, the RowProperties.RowEdit property provides a dropdown window that lets you specify the repository item that defines the editor's type, and holds its properties and event handlers. You can assign an item stored within a repository or create a new repository item with default settings. If you create a new repository item, it's automatically added to the control's internal repository.

The example below shows how to use a CalcEdit editor for in-place editing within the Price row.

AssignEditors - Start

  1. At design time, right-click the vertical grid and choose Run Designer from the context menu to invoke the VerticalGrid Designer.

    Concepts - EditorsForEditorRow - 1

  2. In the Designer's Rows page, select the rowPrice row. Click the dropdown button for the RowProperties.RowEdit property and select the CalcEdit item.

    Concepts - EditorsForEditorRow - 2

    This will create a RepositoryItemCalcEdit object, add it to the control's internal repository and assign it to the rowPrice row.

    Concepts - EditorsForEditorRow - 3

  3. Close the VerticalGrid Designer and run the application. If you click a cell in the Price row, the CalcEdit will be invoked, allowing you to enter a cell value using a dropdown calculator.

    AssignEditors - Result

Assign Editors at Runtime

The sample code below performs the same actions as in the design-time example.

using DevExpress.XtraEditors.Repository;
// ...
// Create a repository item corresponding to the CalcEdit control and add it to the Vertical Grid Control's internal repository.
RepositoryItemCalcEdit riCalc = vGridControl1.RepositoryItems.Add("CalcEdit") as RepositoryItemCalcEdit;
// Assign the editor to the rowPrice row.
vGridControl1.Rows["rowPrice"].Properties.RowEdit = riCalc;

Unique Cell Editors

It is possible to assign unique editors for individual cells by handling the VGridControlBase.CustomRecordCellEdit event. See this event to learn more.

Replace Default Editors for Editing

By default, an editor assigned to a Vertical Grid cell is used in both display and edit modes. You can assign a different editor for each mode by handling the VGridControlBase.CustomRecordCellEditForEditing event. In this case, a cell shows data via the display mode editor, and invokes the edit mode editor when a user starts modifying a cell.

VGrid - Editor for editing

Refer to the event description for an example.

See Also