stustarz Posted February 27, 2005 Posted February 27, 2005 Hi I have a user control that inherits from another user control, when the dll is compiled and added to the toolbox, both the base class control and main control are available - both can be used, but obviously i only want the main control to be shown on the toolbox - how can i disable a user control from being added to the toolbox? Thanks Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
stustarz Posted February 27, 2005 Author Posted February 27, 2005 Sorry people! its ok the attribute <ToolboxItem(True/False)> is the one i need! In case anyone else has the same problem :) Cheers Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
Mike_R Posted February 27, 2005 Posted February 27, 2005 Huh, very cool! :cool: Much better than what I was thinking... But I wonder if making the Base Control 'Abstract' ("MustInherit") would have also worked? That attribute is very slick though, no reason to even try my silly idea... Quote Posting Guidelines Avatar by Lebb
stustarz Posted February 28, 2005 Author Posted February 28, 2005 Yeah i was going to go down that route, but then stumbled across the attribute just after i wrote the post. I still wanted the base class available and didnt really want it to be a mustinherit class - so this attribute was "right up my street". One note to those who will use it: By setting the base class attribute <ToolboxItem> to false, all classes that are inheriting it will be unavailable to the toolbox too unless you override the attribute by setting it to true on the class you wish to show :) i suppose thats why they call it inheritance :D Quote Visit: VBSourceSeek - The VB.NET sourcecode library "A mere friend will agree with you, but a real friend will argue."
Mike_R Posted February 28, 2005 Posted February 28, 2005 (edited) LOL :) Funny thing is, this Attribute really makes the Control *almost* MustInherit, right? Sure, the Control could still be created programmatically, but this is not the most usual use for a Control. To use a control, most typically, it's going to be in the Toolbox... and so by adding this <ToolboxItem()> Attribute, the control *effectively* becomes "MustInherit", at least in terms of using the Control at Design Time... Neat, thanks for the heads-up. :cool: [Edit: You know, it's really weird, that the BaseClass shows up like this, eh? I wonder why.... This <ToolboxItem()> tag is a neat *fix*, but it's starting to feel more like a "patch". I wonder what's happening behind the scenes that causes this to occur... For example, if one uses Visual Inheritance of a Form, instantiating the DerivedClass Form does not simultaneously create an instance of a separate BaseClass Form as well! So this Toolbox Control "inheritance" really is sort of odd...] Edited February 28, 2005 by Mike_R Quote Posting Guidelines Avatar by Lebb
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.