Override Mouse Events in UserControl

C

Charles Law

In a user control, is it possible to replace the default mouse events with
my own?

In particular, I want the consumer of my control to get MouseMove events
when the mouse is over my control, so that they can change the cursor.
However, my control has several standard controls on it, and the consumer of
my control only gets MouseMove events when the mouse is over the control
itself, and not when it is over the standard controls. Therefore, I want to
raise/invoke the MouseMove event myself, when the mouse moves over these
standard controls. How can I do this?

TIA

Charles
 
H

Herfried K. Wagner [MVP]

* "Charles Law said:
In a user control, is it possible to replace the default mouse events with
In particular, I want the consumer of my control to get MouseMove events
when the mouse is over my control, so that they can change the cursor.
However, my control has several standard controls on it, and the consumer of
my control only gets MouseMove events when the mouse is over the control
itself, and not when it is over the standard controls. Therefore, I want to
raise/invoke the MouseMove event myself, when the mouse moves over these
standard controls. How can I do this?

You will have to add handlers for the embedded controls' mouse events
and call the appropriate 'MyBase.On*(sender, e)' method in the handler
in order to raise the event for the usercontrol.
 
C

Charles Law

Herfried, you are the dog's doo-dahs (abstruse English compliment q.v.
"cat's pyjamas").

You clearly know stuff, but honestly, I did look all over before asking the
question. Where are such gems hidden? As far as I can tell this is not
alluded to in the MSDN, and when I looked up the error message "Derived
classes cannot raise base class events" there was no mention of the solution
you gave. Ever thought of writing a book?

Charles
 
H

Herfried K. Wagner [MVP]

* "Charles Law said:
Herfried, you are the dog's doo-dahs (abstruse English compliment q.v.
"cat's pyjamas").
;-)

Ever thought of writing a book?

Yes, but I don't have enough time to do that.
 

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