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
Example 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?