all groups > dotnet windows forms > february 2006 >
You're in the

dotnet windows forms

group:

What does the KeyPressEventsArgs handle property do?


What does the KeyPressEventsArgs handle property do? rsine
2/28/2006 5:53:42 AM
dotnet windows forms: I am trying to understand exactly what the handle property of the
KeyPressEventsArgs does. I thought I could set it to false to prevent
a key from being included into a textbox. For example, if I wanted
only numbers in my textbox and the user pressed an alpha character key,
then I would set the handle property to false and it would be as if the
KeyPress event never occurred thus negating the keystroke. However,
what I am seeing is the pressed key still ends up in my textbox. I
read on MSDN that if the handle is set to false, the operating system
uses a default process to handle the event which is what I figure is
putting the keystroke into the textbox. Is this true or am I
misreading what happens? If it is true, what does setting the handle
property to false actually do?

-Thanks
Re: What does the KeyPressEventsArgs handle property do? Stoitcho Goutsev (100)
2/28/2006 9:09:59 AM
rsine,

You almost got it. You need to set the Handled (past tense) property to
*true* if you want to indicate that you have processed the keypress and you
don't want the framework to do its default processing - putting the
character into the textbox.


--
HTH
Stoitcho Goutsev (100)

[quoted text, click to view]

AddThis Social Bookmark Button