Need Help with Component Directives

T

Tom P.

I'm making a dropdown button (cause I can't get the one on the
toolstrip to work correctly for me).

I'm setting the AutoSize = true; and I'd like it to be ReadOnly. I can
do all that, using "new" to hide the old property and access the old
property using base.AutoSize from inside the subclass... etc.

But what I can't get is the IDE to stop wanting to set the AutoSize
property. This of course leads to a compiler error because the
property is readonly. So I comment those lines out of the designer but
if I touch the control (move it's location, set or delete the text,
anything really) the designer tries to set those values again and I
have to go and comment them out... again.

I know there is a Directive (those statements in brackets that makes
the IDE stop trying to set a property but I can't find it. There's
even one to remove it from the Property list, but I can't find that
either.

Any help would be great, especially if you could tell me where to find
all those cute little directives... that'd be awesome.

Tom P.
 
T

Tom P.

First, you should not be hiding the old property.  Use the "override"  
keyword and override it.

Well, some of them (like Button.Image) are not overridable so I have
to do it the other way. But, the ones I can override I am.

[...]
I know there is a Directive (those statements in brackets that makes
the IDE stop trying to set a property but I can't find it. There's
even one to remove it from the Property list, but I can't find that
either.

They are called "attributes".  You can use either [Browsable(false)] to 
hide the property altogether, or [ReadOnly(true)] to show it, but not  
allow it to be changed in the Designer.

Ahh! Thank you (and thanks for letting me know what they are called).
This is my first foray into component crfeation and I'm not up on all
the terms.
I'm not sure of the best place to find them.  But one place to look is in  
the list of sub-classes for the Attribute class (near the end of the page):http://msdn.microsoft.com/en-us/library/system.attribute.aspx

They are sorted by fully-qualified name, so all the System.ComponentModel 
namespace attributes are together.

Pete

Thank you very much for that. That will be an enormous help.

Tom P.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top