OBSOLETE:
This example is obsolete. We've introduced the RepositoryItemAnyControl class and the corresponding IAnyControlEdit interface in v14.2, which can be used for this purpose. See the How to implement an embedded Chart Control example demonstrating how to implement this approach.
NOTE:
This example is created only for demonstration purposes and we don't recommend using this approach in your application, because it has many limitations and requires writing a lot of custom code. If none of DevExpress XtraEditors are suitable for you and you want to put a custom control in a GridControl cell, pleasecontact DevExpress support and describe the desired layout to us. We will do our best to find an acceptable solution for you.
This example demonstrates how a custom UserControl can be used as an in-place editor in GridView, TreeList, Ribbon and Vertical Grid. As described in the A128 Knowledge Base, it is not possible to just place a control within a cell, because cells are not controls. When a cell's editor is not activated, its content is drawn via a painter. So, in our example, we have created a painter to draw the entire UserControl's content. All cells in GridView will be drawn using this painter until an end-user clicks a cell. In this case, an actual instance of the UserControl class will be created. Controls inherited from the BaseEdit class are drawn via their painters, other controls are drawn via the DrawToBitmap function. In case of 3rd-party controls, you need to draw them manually. If you want to use your custom control in GridView or other controls, you need to implement the IEditValue interface in it.
See also: How to work with the editor's painter, and view info classes in a descendant
Question Comments
Added By: Jaix Software at: 3/6/2013 8:05:36 PM
This example does not work with DateEdit in a menu bar. There appears to be a display issue, as when focus is lost nothing is display. Re-selecting the control and the dates come back.
Added By: D. Samsonoff at: 4/25/2013 2:58:12 AMYou probably would want to expose Control rather than UserControl to meet broader requirements.
Added By: Christophe Keller @ PTS at: 12/12/2013 1:34:26 AMHi,
In your example, if I click on a different cell in the table in Form1, the cell turns white for a short amount of time before the editor is active. How can I avoid this?
Added By: Satwant Sandhu at: 2/10/2016 7:59:07 AM How do we modify this so that the custom control is only used when editing. I have a custom text box that I use for entry, but once the user is no longer in edit mode then I want to show the default cell rendered (i.e. a label).I do not want my custom editor being painted in every cell. Added By: Svetlana (DevExpress Support) at: 2/10/2016 11:46:58 PM
Hello,
To process your recent post more efficiently, I created a separate ticket on your behalf: T344393: How to use a custom editor only for editing in a grid. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.