KeyPressEventArgs.Handled vs KeyEventArgs.Handled

  • Thread starter Thread starter Houston Keach
  • Start date Start date
H

Houston Keach

I'm evidently confused about the difference between
KeyPressEventArgs.Handled & KeyEventArgs.Handled. Setting
KeyEventArgs.Handled=true in the KeyDown event seems to have no effect
on the handling of the key in the control. On the other hand, setting
KeyPressEventArgs.Handled=true does seem to prevent further processing
of the keystroke. What's the difference?

--Houston
 
Could you please describe what you are trying to accomplish. Please note,
that setting KeyEventArgs.Handled to true in the KeyDown event handler does
not prevent firing of the KeyPress and KeyUP events.

Best regards,
Sergiy.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
| From: Houston Keach <>
| Newsgroups: microsoft.public.dotnet.framework.compactframework
| Subject: KeyPressEventArgs.Handled vs KeyEventArgs.Handled
| Date: Tue, 11 Nov 2003 14:55:26 -0600
| Organization: Posted via Supernews, http://www.supernews.com
| Message-ID: <[email protected]>
| X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
| MIME-Version: 1.0
| Content-Type: text/plain; charset=us-ascii
| Content-Transfer-Encoding: 7bit
| X-Complaints-To: (e-mail address removed)
| Lines: 8
| Path:
cpmsftngxa06.phx.gbl!TK2MSFTNGXA06.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP0
8.phx.gbl!newsfeed00.sul.t-online.de!t-online.de!news-spur1.maxwell.syr.edu!
news.maxwell.syr.edu!sn-xit-03!sn-xit-04!sn-xit-06!sn-post-01!supernews.com!
corp.supernews.com!not-for-mail
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.compactframework:38316
| X-Tomcat-NG: microsoft.public.dotnet.framework.compactframework
|
| I'm evidently confused about the difference between
| KeyPressEventArgs.Handled & KeyEventArgs.Handled. Setting
| KeyEventArgs.Handled=true in the KeyDown event seems to have no effect
| on the handling of the key in the control. On the other hand, setting
| KeyPressEventArgs.Handled=true does seem to prevent further processing
| of the keystroke. What's the difference?
|
| --Houston
|
 
I want to handle the arrow keys and prevent the caret from being moved
in the focused textbox.

thanks--Houston
 
Unfortunately you can't set the caret position inside the textbox or prevent
the underlying textbox implementation from moving it.
 
Well, you *could* subclass the control with a C/C++ DLL, for example, and
catch those keys and not pass them to the default control procedure. It's
not a all-managed-code thing...

Paul T.

Ed Kaim said:
Unfortunately you can't set the caret position inside the textbox or prevent
the underlying textbox implementation from moving it.
 
Back
Top