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