The compiler objects because OnMouseDown() is a protected method. Pretty intentional, it stops you from shooting yourself in the foot. Your are certainly aiming that gun, the e
object does not have the correct property values. The Location
, X
and Y
properties are wrong, they are relative from the control's client area.
You will need to add a public method to whatever class represents the drawCanvas object so you can call OnMouseDown(). And take care of giving the MouseEventArgs object the proper values, that typically requires the PointToScreen and PointToClient methods to translate the coordinate value. If it is a PictureBox object then you'll need to derive from it so you can add that public method. All and all a very strong hint that you are doing it wrong.