e.handled in KeyDown Event

  • Thread starter Thread starter Richard Day
  • Start date Start date
R

Richard Day

Setting e.handled = true in the KeyDown event for a
textbox does not prevent the character from appearing in
the textbox.

The following MSDN article suggests setting a global
variable in the KeyDown event and then in the KeyPress
event setting e.handled = true depending on the global
variable.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfSystemWindowsFormsKeyEventArgsClassKeyC
odeTopic.asp

This seems a very messy solution to me.

Has anyone else experienced this issue? I am assuming
this is intentional behavior and not a bug - but why?
 
Back
Top