thanks guys for the response.
i found the solution about an hour after posting this question.
to trap the keystroke, one needs to set the boolean to true in
e.handled for KeyUp, KeyDown and KeyPress.
as to the question why i wanted to display the keystroke in MessageBox...
i can't get the correct ASCII code for capital and lower case letter.
seems like it always display the same KeyValue.
and the KeyValue always for the capital letter.
and yes, the CAPS LOCK is OFF.
anyhow, problem solved now.
case closed. :-)
"Peter Duniho" wrote:
> On Sat, 18 Apr 2009 03:45:01 -0700, Ada <(E-Mail Removed)>
> wrote:
>
> > hi folks,
> >
> > i've been searching for solution for a couple days now.
> > hoping someone here have an easy solution.
> >
> > i have a winform with one textbox.
> > i'm trying to capture the keystroke and display the ASCII code
> > in MsgBox before it displays in the textbox.
> >
> > i tried KeyValue and KeyCode in KeyPress event but those seem to display
> > only the capital letter. [...]
>
> If you are looking at a KeyValue and KeyCode property, you're not handling
> the KeyPress event.
>
> On the other hand, if you do handle the KeyPress event, you will get a
> character code, just as you seem to want.
>
> I don't think you should be using MsgBox in C# (the proper
> System.Windows.Forms class is MessageBox), and it's not clear to me why
> it's useful to have a MsgBox or MessageBox display with each key-press.
> But if that's what you want, it should work as long as you handle the
> right event.
>
> Pete
>
|