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

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
 
R

Rick Mogstad

you are calling mybase.onkeyup, which will always raise the event. you are
not handling the event, you are simply overriding it.
 
D

**Developer**

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.
 
R

Rick Mogstad

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.
 
D

**Developer**

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
 

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