How can I make a property not show in the properties window?

  • Thread starter Thread starter Just Me
  • Start date Start date
Jay, another question: If I read your reply correctly, if I shadow
AutoScroll property and set the designer and browsable to False, and If I
want the AutoScroll to be False, then I must set it in the "New" procedure?
Is this correct?
 
Dennis,
Just one more question on Shadows (I know you don't like them)
Its not that I don't like them per se, they are a very powerful & useful
tool, I use them when they are needed. However you need to use extreme
caution when using them, hence my cautioning others!
then I assume
MyBase.Property procedure will not be executed
Ah! There's the rub!

Sometimes it might be, sometimes not.

Remember that Shadows is anti-polymorphism, hence my

Try the following:

Public Class Shadow

Public Shadows Function ToString() As String
Return "This is a shadow!"
End Function

End Class

Dim s As New Shadow
Dim o As Object = s

Debug.WriteLine(s, "1")
Debug.WriteLine(o, "2")
Debug.WriteLine(s.ToString(), "3")
Debug.WriteLine(o.ToString(), "4")

Polymorphism states that all four lines should print "This is a shadow!",
however the Shadows keyword only allows line 3 to say it. The other 3 lines
are calling the Object.ToString & not Shadow.ToString

If you change ToString to be Overrides, then "This is a shadow!" will print
on all four lines. As Shadow.ToString is overriding (replacing)
Object.ToString.

Public Overrides Function ToString() As String


Calling MyBase.AutoScroll in the sample, simply ensures that AutoScroll
behaves consistently despite the Shadow. If you used your own variable,
calling ScrollableControl.AutoScroll

Consider the following AutoScroll that does its own thing with Shadows.

Public Class MyControl
Inherits UserControl

Private m_autoScroll As Boolean

<Browsable(False)> _
Public Shadows Property AutoScroll() As Boolean
Get
Return m_autoScroll
End Get
Set(ByVal value As Boolean)
m_autoScroll = value
End Set
End Property

...

End Class

Consider the following in a form someplace:

For Each child As Control in My.Controls
If TypeOf child Is ScrollableControl Then
Dim sc As ScrollableControl = DirectCast(child,
ScrollableControl)
sc.AutoScroll = False
End If
Next

The MyControl.m_autoScroll value will not be updated as MyControl shadows
ScrollableControl.AutoScroll, calling AutoScroll via the ScrollableControl
variable will call ScrollableControl.AutoScroll & not
MyControl.AutoScroll...

Hope this helps
Jay
 
Thanks for explaination. I will restrict my use of Shadows code that won't
be used by anyone else unless I have to. I wonder why M'soft didn't allow
overridding properties such as autoscroll. Anyway, thanks again.
 
Dennis,
AutoScroll is overridable! we were just using it as the original poster
asked about it.

Hope this helps
Jay
 

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

Back
Top