Skip to main content

VGridControlBase.CustomRecordCellEdit Event

Allows you to associate an editor with an individual cell. To avoid performance issues and increased memory consumption, assign repository items that already exist in the VGridControl.RepositoryItems collection. Do not create new repository items in this handler.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v23.2.dll

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

Declaration

public event GetCustomRowCellEditEventHandler CustomRecordCellEdit

Event Data

The CustomRecordCellEdit event's data class is GetCustomRowCellEditEventArgs. The following properties provide information specific to this event:

Property Description
CellIndex Gets the processed cell’s index. Inherited from RowCellEventArgs.
RecordIndex Gets the index of the record containing the processed cell. Inherited from RowCellEventArgs.
RepositoryItem Gets or sets the editor assigned to the processed cell.
Row Gets the processed row. Inherited from RowEventArgs.

Remarks

Use the RecordIndex and CellIndex event arguments to identify the processed cell. To assign an editor to the cell, use the RepositoryItem event argument. Note that the editor’s repository item should be added to the vertical grid’s RepositoryItems collection.

Important

The RepositoryItem event argument allows you to specify the editor assigned to the processed cell. Do not use this event to update the editor’s settings. Updating an editor’s settings after the control is initialized may lead to unexpected behavior. You can only use this event to assign an editor to the processed cell.

The RowEdit property and the CustomRecordCellEdit event allow you to specify the editor used to display and edit cell values. You can also handle the CustomRecordCellEditForEditing event to specify the editor used to edit cell values only.

See the following help topics for more information: Assign Editors to Editor Rows and Assigning Editors to Multi-Editor Rows.

Example

The code below assigns editors to cells in the Quantity row.

VGrid - Custom Cell Edit

public partial class Form1 : Form {
     public Form1() {
         InitializeComponent();
         this.Load += Form1_Load;
     }

     RepositoryItemSpinEdit riSpinEdit = new RepositoryItemSpinEdit();
     RepositoryItemTextEdit riTextEdit = new RepositoryItemTextEdit();
     RepositoryItemCalcEdit riCalcEdit = new RepositoryItemCalcEdit();
     RepositoryItem[] inplaceEditors;

     private void Form1_Load(object sender, EventArgs e) {
         inplaceEditors = new RepositoryItem[] { riSpinEdit, riTextEdit, riCalcEdit };
         vGridControl1.RepositoryItems.Add(riSpinEdit);
         vGridControl1.RepositoryItems.Add(riTextEdit);
         vGridControl1.RepositoryItems.Add(riCalcEdit);
         vGridControl1.CustomRecordCellEdit += VGridControl1_CustomRecordCellEdit;
         riTextEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
         riTextEdit.DisplayFormat.FormatString = "c2";

     }

     private void VGridControl1_CustomRecordCellEdit(object sender, DevExpress.XtraVerticalGrid.Events.GetCustomRowCellEditEventArgs e) {
         if (e.RecordIndex < 3 && e.Row.Properties.FieldName == "Quantity") e.RepositoryItem = inplaceEditors[e.RecordIndex];
     }
 }
See Also