Skip to main content

Assigning Editors To MultiEditor Rows

  • 3 minutes to read

MultiEditor rows are capable of displaying data from several data set fields. Such rows have several data cells within a record and thus you can bind several different editors to a multi editor row.

Multi editor rows publish the Properties.Editors property. This property provides access to the TcxEditorPropertiesCollection instance (or TcxDBEditorPropertiesCollection instance for data-aware rows), containing the properties of the multi editor row items (data cells).

These properties classes (TcxEditorRowItemProperties and TcxDBEditorRowItemProperties, for data-aware multi editor rows) are inherited from the TcxCustomEditorRowProperties class. Thus multi editor row items have functionality in common with simple Editor rows and assigning an editor to an item is similar to assigning editors to the editor row. This topic explains how this can be performed at design- and runtime.

Assigning Editors at Design Time

This example binds both items of a multi editor row to a cxSpinEdit. Follow these steps:

  1. Double-click the vertical grid control to invoke the Row collection editor.

  1. Select the multi editor row to display its properties. Expand the Properties member.

  1. Click the ellipsis button next to the Properties.Editors property to invoke the Editor properties collection editor. Create two row items. For details on creating and setting up multi editor rows, see the Multi Editor Rows topic.

  1. Select the first item and choose cxSpinEdit from the Properties combo box.

  1. Repeat the same action for the second item within the multi editor row.

  2. Run the application.

Assigning Editors at Runtime

The sample code below does the same at runtime:

//...
cxDBVerticalGridMPG.Properties.Editors[0].EditPropertiesClass := TcxSpinEditProperties;
cxDBVerticalGridMPG.Properties.Editors[1].EditPropertiesClass := TcxSpinEditProperties;
//...

The following screenshot shows the vertical grid with editors assigned:

You can specify one editor for displaying data and another editor for editing data within a cell. This is implemented by handling the Row.OnGetEditingProperties and Row.OnGetEditProperties events. These events provide an AProperties parameter that allows you to specify the editor properties class containing settings for the in-place editor. Parameter settings cannot be changed directly. A repository item of the required type must be created instead and then its Properties member can be assigned to the AProperties parameter. This technique is illustrated in the RowsMultiEditorsDemo application shipped with the ExpressVerticalGrid.

This demo shows how to assign two different editors to the merPaymentDescr multi editor row. When data is displayed at runtime, the editor properties are set to TcxCurrencyProperties, and data editing is delegated to TcxCalcEditProperties. The TcxCalcEditProperties are represented via a TcxEditRepositoryCalcItem repository item. Its settings are demonstrated on the following screenshot:

The following code specifies the editor properties for the PaymentAmount row item via the Row.OnGetEditingProperties event handler.

procedure TRowsMultiEditorsDemoMainForm.merPaymentDescrEditors2GetEditingProperties(
  Sender: TcxCustomEditorRowProperties; ARecordIndex: Integer;
  var AProperties: TcxCustomEditProperties);
begin
  AProperties := erepPaymentAmountEditing.Properties;
end;

The following screenshots illustrate the code’s result:

Result Example
The PaymentAmount row item is in display mode
The PaymentAmount row item is in edit mode