How to enable visual inheritance for Developer Express controls

来源:互联网 发布:inline 在c语言中 编辑:程序博客网 时间:2024/05/01 02:38

We have found a way to enable visual inheritance in our controls when they are used in Visual Studio 2005 / 2008. We have tested this solution in all the typical visual inheritance scenarios and haven't noticed any failures yet. But we cannot be completely sure that we have chosen the correct approach and thus we don't enable visual inheritance by default. What causes this doubt is that Microsoft disabled visual inheritance for its controls.

There is a DXDesignKeys tool shipped with the DXperience suite. It adds a new key to the registry and is capable of changing its state. When this key is present and enabled, Developer Express controls allow visual inheritance. If it is not present or disabled, visual inheritance is prohibited just as with standard controls (this is the default behavior).

Tool file path:

D:\Program Files (x86)\DevExpress 13.2\Components\Tools\Components\DXDesignKeys.exe

 

This problem is actually caused by a limitation of the Visual Form Inheritance mechanism. Note that theBar.ItemLinks property is a collection. VFI doesnot fully support collections. It does not inherit collections as one might expect. Collections are simplycopied. So, you cannot change collections on derived forms, you can justadd new elements. Thus, the newly added items are displayed at the last position on a toolbar.

As the most effective solution in this instance, we recommend that you create all the required toolbars and items at design time, but manage item linksprogrammatically. This way, there is no need to store collections. Another approach is to put Item Links on toolbars only on those forms, which are actually used in your application, not on base forms.

See Also:
Can I use the grid on an inherited form or user control?
How to enable visual inheritance for Developer Express controls

 

0 0