Back to Devexpress

VGridControlBase.CustomRecordCellEdit Event

windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-bd9a7f7e.md

latest7.2 KB
Original Source

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.v25.2.dll

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

Declaration

csharp
public event GetCustomRowCellEditEventHandler CustomRecordCellEdit
vb
Public Event CustomRecordCellEdit As GetCustomRowCellEditEventHandler

Event Data

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

PropertyDescription
CellIndexGets the processed cell’s index. Inherited from RowCellEventArgs.
RecordIndexGets the index of the record containing the processed cell. Inherited from RowCellEventArgs.
RepositoryItemGets or sets the editor assigned to the processed cell.
RowGets 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.

csharp
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];
     }
 }
vb
Partial Public Class Form1
     Inherits Form

     Public Sub New()
         InitializeComponent()
         AddHandler Me.Load, AddressOf Form1_Load
     End Sub

     Private riSpinEdit As New RepositoryItemSpinEdit()
     Private riTextEdit As New RepositoryItemTextEdit()
     Private riCalcEdit As New RepositoryItemCalcEdit()
     Private inplaceEditors() As RepositoryItem

     Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
         inplaceEditors = New RepositoryItem() { riSpinEdit, riTextEdit, riCalcEdit }
         vGridControl1.RepositoryItems.Add(riSpinEdit)
         vGridControl1.RepositoryItems.Add(riTextEdit)
         vGridControl1.RepositoryItems.Add(riCalcEdit)
         AddHandler vGridControl1.CustomRecordCellEdit, AddressOf VGridControl1_CustomRecordCellEdit
         riTextEdit.DisplayFormat.FormatType = DevExpress.Utils.FormatType.Numeric
         riTextEdit.DisplayFormat.FormatString = "c2"

     End Sub

     Private Sub VGridControl1_CustomRecordCellEdit(ByVal sender As Object, ByVal e As DevExpress.XtraVerticalGrid.Events.GetCustomRowCellEditEventArgs)
         If e.RecordIndex < 3 AndAlso e.Row.Properties.FieldName = "Quantity" Then
             e.RepositoryItem = inplaceEditors(e.RecordIndex)
         End If
     End Sub
 End Class

See Also

RowEdit

CustomRecordCellEditForEditing

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace