Back to Devexpress

ColumnView.ActiveEditor Property

windowsforms-devexpress-dot-xtragrid-dot-views-dot-base-dot-columnview-bf8e7dc4.md

latest9.0 KB
Original Source

ColumnView.ActiveEditor Property

Gets a View’s active editor.

Namespace : DevExpress.XtraGrid.Views.Base

Assembly : DevExpress.XtraGrid.v25.2.dll

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

Declaration

csharp
[Browsable(false)]
public override BaseEdit ActiveEditor { get; }
vb
<Browsable(False)>
Public Overrides ReadOnly Property ActiveEditor As BaseEdit

Property Value

TypeDescription
BaseEdit

The currently active editor. null ( Nothing in Visual Basic) if there are no active editors at the time.

|

Remarks

When a user starts to edit a cell value, the grid creates an editor for the cell. When a user has completed the value change, the grid destroys the cell editor. Thus, there can be only one active editor instance at any moment.

Use the ActiveEditor property to return the current active editor. If no cell editor is currently active, the ActiveEditor returns null ( Nothing in Visual Basic).

You can use the ActiveEditor property to change editor settings dynamically. This property is also useful if you need to perform specific actions (such as open the editor’s dropdown window, etc.) when users activate particular editors or when they want to perform specific actions. Note that you will need to handle the ColumnView.ShownEditor event to respond to editor activation.

Note : the ActiveEditor property returns a BaseEdit object. This object is the base for all in-place editors in Grid Views. Thus, you may need to typecast to use editor-specific properties.

Note

Detail pattern Views do not contain data and they are never displayed within XtraGrid. So, the ActiveEditor member must not be invoked for these Views. The ActiveEditor member can only be used with Views that display real data within the Grid Control. Use the following methods to access these Views with which an end user interacts at runtime.

The code sample below illustrates how to populate an empty editor with the current date.

csharp
EmployeesGridView.ShownEditor += EmployeesGridView_ShownEditor;

private void EmployeesGridView_ShownEditor(object sender, EventArgs e)
{
    ColumnView view = (ColumnView)sender;
    if (view.FocusedColumn.FieldName == "VacationDate" && view.ActiveEditor.EditValue=="")
    {
        view.ActiveEditor.EditValue = DateTime.Now.ToString("MM/dd/yyyy");
    }

}
vb
Private EmployeesGridView.ShownEditor += AddressOf EmployeesGridView_ShownEditor

Private Sub EmployeesGridView_ShownEditor(ByVal sender As Object, ByVal e As EventArgs)
    Dim view As ColumnView = DirectCast(sender, ColumnView)
    If view.FocusedColumn.FieldName = "VacationDate" AndAlso view.ActiveEditor.EditValue="" Then
        view.ActiveEditor.EditValue = Date.Now.ToString("MM/dd/yyyy")
    End If

End Sub

The following code snippets (auto-collected from DevExpress Examples) contain references to the ActiveEditor property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

winforms-grid-toggle-checkbox-state-with-one-click/CS/Form1.cs#L66

csharp
view.ShowEditor();
CheckEdit edit = view.ActiveEditor as CheckEdit;
if (edit == null) return;

winforms-richedit-in-an-active-grid-cell/CS/Form1.cs#L22

csharp
if (columnView != null) {
    RichTextEdit activeEditor = columnView.ActiveEditor as RichTextEdit;

winforms-filter-lookup-column-based-on-another-lookup-column/CS/DxSample/MainForm.cs#L22

csharp
if (view.FocusedColumn.FieldName == "CityCode") {
    LookUpEdit editor = (LookUpEdit)view.ActiveEditor;
    string countryCode = Convert.ToString(view.GetFocusedRowCellValue("CountryCode"));

winforms-grid-image-slider-cell-editor/CS/WindowsFormsApplication202/ImageSliderHelper.cs#L36

csharp
GridView view = sender as GridView;
AnyControlEdit edit = view.ActiveEditor as AnyControlEdit;
if (edit != null) {

winforms-grid-change-checkbox-state-single-click-in-multi-select-mode/CS/Form1.cs#L47

csharp
gridView1.ShowEditor();
CheckEdit edit = gridView1.ActiveEditor as CheckEdit;
if (edit == null) return;

winforms-grid-toggle-checkbox-state-with-one-click/VB/Form1.vb#L59

vb
view.ShowEditor()
Dim edit As CheckEdit = TryCast(view.ActiveEditor, CheckEdit)
If edit Is Nothing Then Return

winforms-richedit-in-an-active-grid-cell/VB/Form1.vb#L23

vb
If columnView IsNot Nothing Then
    Dim activeEditor As RichTextEdit = TryCast(columnView.ActiveEditor, RichTextEdit)
    If activeEditor IsNot Nothing Then

winforms-filter-lookup-column-based-on-another-lookup-column/VB/DxSample/MainForm.vb#L24

vb
If view.FocusedColumn.FieldName = "CityCode" Then
    Dim editor As LookUpEdit = CType(view.ActiveEditor, LookUpEdit)
    Dim countryCode As String = Convert.ToString(view.GetFocusedRowCellValue("CountryCode"))

winforms-grid-image-slider-cell-editor/VB/WindowsFormsApplication202/ImageSliderHelper.vb#L40

vb
Dim view As GridView = TryCast(sender, GridView)
Dim edit As AnyControlEdit = TryCast(view.ActiveEditor, AnyControlEdit)
If edit IsNot Nothing Then

winforms-grid-change-checkbox-state-single-click-in-multi-select-mode/VB/Form1.vb#L41

vb
gridView1.ShowEditor()
Dim edit As CheckEdit = TryCast(gridView1.ActiveEditor, CheckEdit)
If edit Is Nothing Then Return

See Also

Edit Data. Create Cell Editors. Validate User Input

ColumnView Class

ColumnView Members

DevExpress.XtraGrid.Views.Base Namespace