Inherit and control properties.

  • Thread starter Thread starter shawncraig
  • Start date Start date
S

shawncraig

I've written a control and Inherited a button but I only want to show
only the custom properties that I made. Is there a way to hide the
rest?
 
hi, i think you can override each method and property you don't want to
expose

some like
pirvate overrides sub xyx(byval e as eventargs )
mybase.xyx(e)
end sub

and
private overrides property ...

etc.


I hope this helps.
Greetings, Sergio E.
 
I've written a control and Inherited a button but I only want to show
only the custom properties that I made. Is there a way to hide the
rest?

If you don't want any of the button properties, then you should create
your class inherited from UserControl and drop a button into it.
 
I've written a control and Inherited a button but I only want to show
only the custom properties that I made. Is there a way to hide the
rest?

Define "hide".
If you want to "remove" them so they're not accessible in code, then
strictly; no you can't. That would break the basic principles of
Inheritance.

If you just want to hide them from the Properties window, then you have
to override/shadow each and every one, decorating it with the
Browsable(False) attribute.
To be honest, I wouldn't think this was worth the effort.

If you want to limit the properties/methods you get to play with in the
Intellisense while you're coding, look at creating an Interface that
includes these and declare your Button as the Interface Type, rather
than the actual Class, as in

Interface ICustomButton
Property ButtonText() as String
. . .
End Interface

Class CustomButton
Implements ICustomButton
. . .
Property ButtonText() As String _
Implements ICustomButton.ButtonText
. . .
End Class

Class Form1
Private btnCustom1 as ICustomButton _
= New CustomButton()
. . .

/But/ this almost certainly won't work in the Forms Designer within the
IDE!

HTH,
Phill W.
 
Shawn,

I never saw any solution for that.

The real controls have as well properties which you see that are inheritted,
some of those don't even work.
AFAIK is one of those the background color from the picturebox.

For the rest read Phil his reply.

Cor
 
Back
Top