Having a problem implementing 'OverRides'

I'm trying to create a derived class for 'Panel' and override the mouse methods as follows:

Public Class CustomPanel
    Inherits Panel
    Private _mousedown As Boolean = False
    Private offsetX, offsetY As Integer

    Protected Shadows Sub OnMouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        _mousedown = True
        offsetX = e.X
        offsetY = e.Y
    End Sub

    Protected Shadows Sub MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        _mousedown = False
    End Sub

    Protected Shadows Sub OnMouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If (_mousedown) Then
            Me.Left = e.X + Me.Left - offsetX
            Me.Top = e.Y + Me.Top - offsetY
        End If
    End Sub

End Class

I'm using Shadows there, and it compiles okay. But, those functions never actually fire if I at a break point.

And if I try and change 'Shadows' to 'Overrides' then I get the error:

sub 'OnMouseDown' cannot be declared 'Overrides' because it does not override a sub in a base class.

And it wont compile.
As you can probably tell, I'm simply trying to move the panel around using the mouse.
TIA!      
LVL 11
L00MAsked:
Who is Participating?
 
Göran AnderssonConnect With a Mentor Commented:
You have specified a different set of parameters in the method, so you are not overriding the method that exists in the Panel class. This is what the signatures should look like:

Protected Shadows Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)

Protected Shadows Sub OnMouseUp(ByVal e As System.Windows.Forms.MouseEventArgs)

Protected Shadows Sub OnMouseMove(ByVal e As System.Windows.Forms.MouseEventArgs)
0
 
L00MAuthor Commented:
That worked for the OnMouseUp and OnMouseMove subs, but this:

Public Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)

Gives me the error:

'Public Overrides Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)' cannot override 'Protected Overridable Sub OnMouseDown(e As System.Windows.Forms.MouseEventArgs)' because they have different access levels.

Any ideas?
0
 
L00MAuthor Commented:
nevermind. Changed Public to Protected and all is well.

Thanks!
0
All Courses

From novice to tech pro — start learning today.