Events Disappear

  • Thread starter Thread starter Martijn Mulder
  • Start date Start date
M

Martijn Mulder

As soon as I add a UserControl to the Controls-property of my Form, the Form
does not get any MouseEvent or KeyEvent anymore. When there is no
UserControl added, the Form does get all the events.

How can I make both UserControl and Form get events?
 
Hello,
About which events are you talking about? If you want to do some work
by consuming the WinForm controls placed on the user control than you
will have to raise them from with in the user control and consume the
user control events.
HTH. Cheers :)

Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
 
Hi,

I could bet that I read somewhere that this is by design, than when a form
has any control in it the form will not receive these events. I cannot find
it right now though :(
 
Martijn said:
As soon as I add a UserControl to the Controls-property of my Form, the Form
does not get any MouseEvent or KeyEvent anymore. When there is no
UserControl added, the Form does get all the events.

How can I make both UserControl and Form get events?

I think Ignacio is right. When the UserControl has focus, it will get
the events. If you need the form to process them first, you can handle
the Control.PreProcessMessage or Control.PreProcessControlMessage
events.

For keyboard events, you can set the KeyPreview property to true.
 
Back
Top