Log In
[Expand]General Information
[Collapse]WinForms Controls
 [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
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
   [Collapse]Data Editing
    [Expand]Edit Form
    [Expand]Editing via Code
    [Collapse]In-place Editors
      In-place Editors Overview
      Assigning Editors for In-Place Editing
      Assigning Editors to Columns and Card Fields
      Assigning Editors to Individual Cells
      Showing and Hiding Editors
    [Expand]Input Validation
    [Expand]New Item Row
     Tutorial: Add or Remove Rows
     Tutorial: Data Input Validation
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [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]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[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. Programmatic editor control is useful if you want to facilitate quick data input. For instance, you can display an editor for a specific cell when the application starts, so end-users can start typing immediately. Or you can navigate to a specific cell and activate its editor at runtime to help users only navigate through particular data cells .

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

The information in this topic is divided into three parts

Expanded Online Videos

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 ColumnView.ShowingEditor event fires each time a cell editor is about to be displayed. This implies that the cell for which it is displayed is focused. Thus, you can use the ColumnView.FocusedRowHandle and ColumnView.FocusedColumn properties to identify it. When the cell has been determined, you can allow or prohibit displaying its editor using the event's Cancel parameter. If it is set to true, the editor will not be displayed.

The ColumnView.ShowingEditor event handler below prohibits editing records whose Country field value is 'Germany'. (The ColumnView.GetRowCellValue method is used to obtain the Country column's value within the focused record).

Expanded Showing and Hiding Editors

The focused cell's editor can be invoked by calling the BaseView.ShowEditor method. Thus, if you want to edit a specific cell, you must first focus it. Please refer to the Focusing Cells and Moving Row Focus topics for details on focusing cells.

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

Note: you can also use the grid control's BaseView.PostEditor method to save changes without closing the editor.

The Grid Control also enables you to perform actions each time an editor is activated or closed either by end-users or programmatically. This can be done by handling the ColumnView.ShownEditor and ColumnView.HiddenEditor events respectively. The first one can be used to facilitate work 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 this topics next section). The ColumnView.HiddenEditor event can be used, for instance, if you want to navigate to a 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 ColumnView.ActiveEditor property. This property returns a BaseEdit object (the common ancestor for all editors in the DevExpress Editors Library). Thus, you need to cast to the appropriate type to use editor-specific properties. Note: if no editor is active currently, the property returns null (Nothing in Visual Basic).

When a View's data source is modified externally (for instance, if there are several users working with the same database), the ColumnView.RefreshEditor method synchronizes the active editor's content with the corresponding cell content.

Using the active editor, you can obtain and modify the cell value being edited. This is done by using the ColumnView.EditingValue property. This property also returns null (Nothing in Visual Basic) while no editing is being done.

These properties enable you to customize the editor and the edited value as your needs dictate. For instance, the following sample code handles the ColumnView.ShownEditor event to open the popup window of the DateEdit editor and to write the current date to the edited text. The operations are performed when the editor is opened for the 'OrderDate' column (the DateEdit editor must be bound to it).

Expanded See Also

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