Back to Devexpress

VGridControlBase.CustomRecordCellEditForEditing Event

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

latest7.0 KB
Original Source

VGridControlBase.CustomRecordCellEditForEditing Event

Allows you to assign a custom editor to a cell for in-place editing, and so override the default row editor, which is by default, used both in display and edit modes. 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 CustomRecordCellEditForEditing
vb
Public Event CustomRecordCellEditForEditing As GetCustomRowCellEditEventHandler

Event Data

The CustomRecordCellEditForEditing 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

You can assign an in-place editor to a row via the RowProperties.RowEdit property, or to an individual row cell via the VGridControlBase.CustomRecordCellEdit event. This editor will be used to represent a cell’s contents in display mode (when the cell isn’t currently edited), and by default in edit mode. If you need to provide different editors to represent a cell’s contents differently in display and edit modes, handle the CustomRecordCellEditForEditing event.

To assign an editor to a cell for in-place editing while handling the CustomRecordCellEditForEditing event, assign a corresponding repository item to the RepositoryItem parameter. Note that the repository item must belong to the grid control’s RepositoryItems collection (see the inherited EditorContainer.RepositoryItems property) or to an external repository (see the EditorContainer.ExternalRepository property).

The following example illustrates how to assign the ProgressBarControl for all “Quantity” cells, and replace this editor with a SpinEdit when a user starts modifying a cell value.

csharp
using DevExpress.XtraEditors.Repository;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace VGrid_Editors_Test {
    public partial class Form1 : Form {
        RepositoryItem editorForDisplay, editorForEditing;
        public Form1() {
            InitializeComponent();
            this.Load += Form1_Load;
            vGridControl1.CustomRecordCellEditForEditing += VGridControl1_CustomRecordCellEditForEditing;
        }

        private void Form1_Load(object sender, EventArgs e) {
            // Initialize the editors and assign the default editor to a column.
            editorForDisplay = new RepositoryItemProgressBar();
            editorForEditing = new RepositoryItemSpinEdit();
            vGridControl1.RepositoryItems.AddRange(
              new RepositoryItem[] { editorForDisplay, editorForEditing });
            vGridControl1.GetRowByFieldName("Quantity").Properties.RowEdit = editorForDisplay;
        }

        private void VGridControl1_CustomRecordCellEditForEditing(object sender, DevExpress.XtraVerticalGrid.Events.GetCustomRowCellEditEventArgs e) {
            if (e.Row.Properties.FieldName == "Quantity")
                e.RepositoryItem = editorForEditing;
        }
    }
}
vb
Imports DevExpress.XtraEditors.Repository
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms

Namespace VGrid_Editors_Test
    Partial Public Class Form1
        Inherits Form

        Private editorForDisplay, editorForEditing As RepositoryItem
        Public Sub New()
            InitializeComponent()
            AddHandler Me.Load, AddressOf Form1_Load
            AddHandler vGridControl1.CustomRecordCellEditForEditing, AddressOf VGridControl1_CustomRecordCellEditForEditing
        End Sub

        Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
            ' Initialize the editors and assign the default editor to a column.
            editorForDisplay = New RepositoryItemProgressBar()
            editorForEditing = New RepositoryItemSpinEdit()
            vGridControl1.RepositoryItems.AddRange(New RepositoryItem() { editorForDisplay, editorForEditing })
            vGridControl1.GetRowByFieldName("Quantity").Properties.RowEdit = editorForDisplay
        End Sub

        Private Sub VGridControl1_CustomRecordCellEditForEditing(ByVal sender As Object, ByVal e As DevExpress.XtraVerticalGrid.Events.GetCustomRowCellEditEventArgs)
            If e.Row.Properties.FieldName = "Quantity" Then
                e.RepositoryItem = editorForEditing
            End If
        End Sub
    End Class
End Namespace

See Also

RowEdit

CustomRecordCellEdit

VGridControlBase Class

VGridControlBase Members

DevExpress.XtraVerticalGrid Namespace