Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

Visit: VBSourceSeek - The VB.NET sourcecode library

 

 

"A mere friend will agree with you, but a real friend will argue."
Posted

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...

Posting Guidelines

 

Avatar by Lebb

Posted

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

Visit: VBSourceSeek - The VB.NET sourcecode library

 

 

"A mere friend will agree with you, but a real friend will argue."
Posted (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 by Mike_R

Posting Guidelines

 

Avatar by Lebb

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...