Description:
I would like to add the XtraGrid to a UserControl and then add this to a form. However I would also like to use the XtraGrid Designer on the form that I have dropped the UserControl on. Is this possible?
Answer:
The grid is an internal object of your UserControl instance and it cannot be modified. The same situation is true for any other control, e.g. Button; - you cannot modify it when your UserControl is embedded in a form. The UserControl's inner component in this case is a private field, not a public property which would know how to serialize itself into the Designer Generated Code. Therefore, the inner grid control is inaccessible and cannot be modified via its designer or the Property Window.
The solution is to create an inherited UserControl from your base control with the XtraGrid, configure the grid on it as needed, and then use this inherited UserControl on your forms. The inherited control from the existing UserControl can be created via the Project | Add New Item menu command in Visual Studio.
The "inherited UserControl" means that you create a new control, that derives all the structure, properties and methods of the base UserControl. However, it is not just a copy of the Base control. It allows you to customize its properties, handle events etc., without changing predefined values at the Base control level. To create the inherited UserControl, you should first create a base UserControl (MainMenu | Project | Add New Item | User Control) and customize it as your needs dictate. After that, you'll be able to create an inherited UserControl. To do this, please perform the following steps:
- Choose the MainMenu | Project | Add New Item menu command;
- Choose the Inherited UserControl object in the dialog;
- After that, the dialog to choose a Base control will be shown. Just choose your UserControl there, and click the "OK" button.
That's all. The inherited UserControl is created and added to the project.
See Also:
Can I use the grid on an inherited form or user control?
How to enable visual inheritance for Developer Express controls
How to create a GridView descendant class and register it for design-time use
Alisher from DE says this is not possible, here: https://www.devexpress.com/Support/Center/Question/Details/Q537216/how-to-use-the-grid-designer-when-the-grid-is-inside-a-usercontrol
Are you both talking about the same thing here ? I would like a solution that helps me "Run designer" of grid control (in another user control) from the main form.
Hello,
I've created a separate ticket on your behalf (T613617: How to use the grid designer when the grid is inside a UserControl). It has been placed in our processing queue and will be answered shortly.