Let's say we created the base control XPanel:
public class XPanel : Paneland its descendant XFinalPanel:
public class XFinalPanel : XPanelWe are to show the XFinalPanel control in the Toolbox and to hide the XPanel. By default both controls should be visible in the Toolbox. There is a ToolboxItem attribute that allows to manage the control visibility. As it is inherited, it sounds logical to write the following code to solve the task:
[ToolboxItem(false)] public class XPanel : Panel ... [ToolboxItem(true)] public class XFinalPanel : XPanelUnfortunately, it doesn't work. The XFinalPanel is shown in the Toolbox, but you can't drag&drop it to the form. The only workaround I've found is to declare XPanel as abstract class. Or, of course, you may let both controls be shown in the toolbox.
No comments:
Post a Comment