What does setting e.Handled = True in KeyUp do?

  • Thread starter Thread starter **Developer**
  • Start date Start date
D

**Developer**

I have a usercontrol that contains the following.

To my surprise the form containing this control get KeyUp events.

Help says that for KeyPress setting e.Handled = True suppresses KeyPress
events but say very little about KeyUp.

What does setting to Handled do?



In the Control I also continue to get KeyPress and KeyUp events.

In them I also have the same code to set e.Handled = True

Thanks



Protected Overrides Sub OnKeyUp(ByVal e As
System.Windows.Forms.KeyEventArgs)

If mReadOnly Then

e.Handled = True

Else

snip...

End If

MyBase.OnKeyUp(e)

End Sub
 
you are calling mybase.onkeyup, which will always raise the event. you are
not handling the event, you are simply overriding it.
 
What does setting e.Handled = True do?

Thanks

Rick Mogstad said:
you are calling mybase.onkeyup, which will always raise the event. you
are not handling the event, you are simply overriding it.
 
when the event is raised, it will check cause subsequent handlers to not be
called. It needs to be set inside of an event handler though, and you are
not.
 
Rick Mogstad said:
when the event is raised, it will check cause subsequent handlers to not
be called. It needs to be set inside of an event handler though, and you
are not.
Thanks
 
Back
Top