[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Collapse]Vertical Grid
   [Expand]Binding to Data
   [Expand]Data Layout: Records, Rows and Cells
   [Collapse]Data Editing and Validation
     In-place Editors
     Assigning Editors to Editor Rows
     Assigning Editors to Multi-Editor Rows
     Showing and Hiding Editors
    Formatting Values
   [Expand]Drag and Drop
   [Expand]Appearance and Custom Painting
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Hit Information
    Batch Modifications
   [Expand]Member Tables
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Showing and Hiding Editors

This topic contains information on how and when cell editors can be invoked and hidden programmatically and how to access the active editor and its value. Programmatically hiding and showing an editor is useful if you want to facilitate data entry or searching. For example, you can display an editor for a specific cell when the application starts, so end-users can immediately start typing. Or you can navigate to a specific cell and activate its editor at runtime to help users navigate through the desired data cells only.

For information on how end-users can invoke editors for data cells, please refer to the Editing Data and Navigating Through Cells topics.

The information in this topic is divided into three parts:

Expanded When Data Cells Can Be Edited by End-Users

A cell editor can be displayed if the following conditions are met:

Let's consider the last condition in detail. The VGridControlBase.ShowingEditor event fires each time a cell editor is about to be displayed. This implies that the cell for which it is displayed is currently focused. Thus, you can use the VGridControlBase.FocusedRow and VGridControlBase.FocusedRecord properties to identify it. When the cell has been determined, you can permit or prohibit its editor from displaying using the event's Cancel parameter. If it is set to true, the editor will not be displayed.

The sample code below handles the VGridControlBase.ShowingEditor event to prohibit the modification of records whose Trademark field value is 'BMW'. (The VGridControlBase.GetCellValue method is used to obtain the Trademark row value within the current record.)

You can use the VGridControlBase.CanShowEditor property of the grid control to determine whether the focused cell can be edited. This property returns true if all the conditions listed are satisfied.

Expanded Showing and Hiding Editors

The focused cell's editor can be invoked by calling the VGridControlBase.ShowEditor method. Thus, if you want to edit a specific cell, you must first focus it by assigning proper values to the VGridControlBase.FocusedRow and VGridControlBase.FocusedRecord properties.

If you want to close the editor programmatically, you can choose one of the two available methods:

Note that you can also use the VGridControlBase.PostEditor method to save changes without closing the editor.

The vertical grid control also enables you to perform specific actions each time an editor is activated or closed either by end-users or programmatically. This can be done by handling the VGridControlBase.ShownEditor and VGridControlBase.HiddenEditor events respectively. The first one can be used to facilitate working with the editor itself. For instance, when using a MemoExEdit editor, you can open its popup window when it is activated (see the example in the following section). The VGridControlBase.HiddenEditor event could be used, for instance, if you want to navigate to the desired cell and activate its editor. The sample code below handles this event to navigate to the next record and activate the editor for the cell residing in the focused row.

Expanded Accessing the Active Editor

When a cell editor is active, you can access it using the control's VGridControlBase.ActiveEditor property. This property returns the BaseEdit object (the common ancestor for all editors in the DevExpress Editors Library). Thus, you need to perform casting to the desired type to use editor-specific properties. Note that if no editor is currently active, the property returns null (Nothing in Visual Basic).

Together with the active editor, you can obtain and modify the cell value currently being edited. This is performed using the VGridControlBase.EditingValue property. This property also returns null (Nothing in Visual Basic) if no editing is occurring at the moment.

The two properties mentioned enable you to customize the editor and the edited value as your needs dictate. For instance, the following sample code handles the VGridControlBase.ShownEditor event to open the popup window of the MemoExEdit editor and write the current date to the edited text. These operations are performed if the editor is opened for the 'Report' row (the MemoExEdit editor must be bound to it).

Expanded See Also

Is this topic helpful?​​​​​​​