Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]Overview
   [Expand]Fundamentals
   [Collapse]Concepts
     Filtering
    [Expand]Layouts
    [Expand]Binding to Data
    [Expand]Rows
    [Expand]Records
    [Expand]Cells
    [Collapse]In-place Editors
      Assigning Editors to Editor Rows
      Assigning Editors to Multi-Editor Rows
      Showing and Hiding Editors
      Validation
     Formatting
    [Expand]Appearances
     Hit Information
    [Expand]Custom Painting
    [Expand]Alpha Blending and Background Images
    [Expand]Customization Form
     Batch Modifications
    [Expand]Drag and Drop
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
   [Expand]Member Tables
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap 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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

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

How would you rate this topic?​​​​​​​