Hiding Inherited properties

  • Thread starter Juan Pedro Gonzalez
  • Start date
J

Juan Pedro Gonzalez

Hi,

I've develpped a reusable UserControl. The only headache it's giving me is
how to hide the inherited properties such as AutoScroll, DockPadding, etc...
wich could cause some visual Anoyances on my control.I've tried

<System.ComponentModel.Browsable(False),
System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableS
tate.Never),
System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.
DesignerSerializationVisibility.Hidden)>

This way the properties are not visible at the property grid, but they are
visible when writting the code (Intelisense). Is there another way to get
rid of them?

Thank you in advance
 
C

Cor Ligthert

Juan,

This is often asked, there has not been a Yes answer with description yet.

You can see it in the standard classes also. If you set the
textbox.backcolor, you can set it, however because of the fact that the
textbox has no background, it does nothing. It is not set the propertygrid,
however you can set it in code as often as you want.

I hope this helps,

Cor
 
P

Phill. W

Juan Pedro Gonzalez said:
The only headache it's giving me is how to hide the inherited
properties .. . .
This way the properties are not visible at the property grid, but
they are visible when writting the code (Intelisense). .. . .
Is there another way to get rid of them?

No. That's one of the basic tenets of Inheritance.

However, you might be able to "side-step" this by declaring
an Interface for your control and creating "duplicate" variables
for each actual control that are defined as the Interface Type,
something like

Interface ITinyTextBox
Property Enabled() As String
Property Text() As String
End Interface

Class myTextBox
Inherits Forms.TextBox
Implements ITinyTextBox
. . .

Then, in your form, the Forms Designer will write

Friend WithEvents txtThing As myTextBox
. . .
txtThing = New myTextBox

Then you can add

Private txtSimpleThing as ITinyTextBox _
= DirectCast( txtThing, ITinyTextBox )

Then use txtSimpleThing in place of txtThing:

Me.txtSimpleThing.Text = ...

And all you'll see are the things defined in the Interface.

HTH,
Phill W.
 

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