PC Review


Reply
Thread Tools Rate Thread

capture keystroke before display in textbox

 
 
Ada
Guest
Posts: n/a
 
      18th Apr 2009
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.
when i input lowercase, the KeyValue is still the same.
example, KeyValue of "A" or "a" are the same value of 65.

any suggestions appreciated.

tia,

 
Reply With Quote
 
 
 
 
Ada
Guest
Posts: n/a
 
      18th Apr 2009
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
>

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to capture keystroke Larry Smith Microsoft Dot NET Framework Forms 5 12th Apr 2007 07:37 PM
Keystroke Capture NickM Microsoft Access Forms 1 8th Sep 2005 06:27 AM
keystroke screen capture Morne Security and Anti-Spyware Community 1 14th Apr 2005 03:05 AM
prevent non-numeric keystroke in textbox Jack Fox Microsoft Dot NET Framework 4 17th Jul 2003 08:56 AM
Re: capture keystroke Dirk Goldgar Microsoft Access VBA Modules 0 11th Jul 2003 04:41 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:58 PM.