KB Article A128
Visible to All Users

How to use a custom control in inplace mode in DevExpress containers

Description:
Is it possible to use third-party editors in a grid cell as the in-place editor?

Answer:
Applies to:
GridControl, TreeList, VGridControl, PivotGridControl, Bars, RibbonControl
Here is how our GridView (and all other editor containers) works:
When the GridView is in regular mode, cells are painted directly on the GridControl's canvas. Depending on the RepositoryItem assigned to a specific column, the GridView obtains a required painter and calls its DrawObject method with required arguments. I.e. cells are not controls, and they don't contain any controls. Then, when you click a cell, its in-place editor is created. To create a corresponding editor, the RepositoryItem's CreateEditor method is executed. This editor has its own Properties object with settings copied from the column's RepositoryItem. At this moment, an active cell contains a true control. However, when it loses focus, its value is posted and it's disposed of. Then, the cell draws an updated content as it does at startup, using a painter.
That's why to embed your custom control into a cell, you should create a custom painter, which will draw the cell's content when its editor is not activated. The grid's in-place editor must be derived from the DevExpress.XtraEditors.BaseEdit class. Sample custom editors are included in the XtraGrid demos. You can find them in the following folders on your disk:
<DevExpress Demos>\XtraEditors\CS\MyControls1
<DevExpress Demos>\XtraEditors\VB\MyControls1
Also, you can find the required code samples at:
http://search.devexpress.com/?q=%22Custom+editor%22+example&p=T4|P0|0&d=16
If you decide to create a grid editor based on your control, we advise that you review the TextEdit.cs module in the XtraEditors source. Our text editor is a container, which actually uses a TextBox (TextBoxMaskBox) control for editing. You will need to create a similar editor with your control inside. Actually, this is a difficult task and you may wish to use one of the following approaches instead:

  1. Put your edit control into the PopupContainerControl component and attach the latter to the PopupContainerEdit repository item used as a column's editor. In this case, your edit control is available via a cell's dropdown window (How to use the Popup Container Editor).
  2. If you need to display any graphic (non-editable) information (Charts or Gauges) in cells, you can populate an unbound column with images based on cell values as described in the A2707 Knowledge Base article.
    If all previous solutions are not suitable for you and you need to have a custom control in inplace mode, you can try to use our custom editor implemented in the E3051 example. It supports displaying any custom control that implements IEditValue interface. However, since this is a very general solution, possibly you need to adapt it to your needs manually.
    See Also:
    How to register a custom editor for use in the XtraGrid
    Custom Editors
    How to put a custom UserControl in a GridView cell

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.