PC Review


Reply
Thread Tools Rate Thread

determine which key is pressed in control?

 
 
Steve
Guest
Posts: n/a
 
      3rd Mar 2004
Hi,

I want to determine which key was pressed in a control,
like a datagrid. I see that in the currentcellchanged
event of a datagrid I can capture keystroke events. I
have tried someting like the following:

Dim ky As New KeyPressEventArgs(Convert.ToChar(27))

but this sets ky to the Escape key. I really want to
capture the number that goes in Convert.ToChar(...). How
can I capture that value?

Thanks,
Steve
 
Reply With Quote
 
 
 
 
Steve
Guest
Posts: n/a
 
      3rd Mar 2004
What I really want to do is to raise the KeyPress event of
the Form or this datagrid control using the up or down
arrow keys. I have set the Form KeyPreview property to
true. The only key that seems to raise any Key events is
the Enter key. Is there any way to raise a Key event
witht the arrow keys?


>-----Original Message-----
>Hi,
>
>I want to determine which key was pressed in a control,
>like a datagrid. I see that in the currentcellchanged
>event of a datagrid I can capture keystroke events. I
>have tried someting like the following:
>
>Dim ky As New KeyPressEventArgs(Convert.ToChar(27))
>
>but this sets ky to the Escape key. I really want to
>capture the number that goes in Convert.ToChar(...). How
>can I capture that value?
>
>Thanks,
>Steve
>.
>

 
Reply With Quote
 
Vikas Ahuja
Guest
Posts: n/a
 
      3rd Mar 2004
Hi Steve,

Try using the KeyDown or KeyUp event. They have a broader range of keys,
including Up and Down arrows.

Hope this helps
Vikas

"Steve" <(E-Mail Removed)> wrote in message
news:656601c40158$7ec27700$(E-Mail Removed)...
> What I really want to do is to raise the KeyPress event of
> the Form or this datagrid control using the up or down
> arrow keys. I have set the Form KeyPreview property to
> true. The only key that seems to raise any Key events is
> the Enter key. Is there any way to raise a Key event
> witht the arrow keys?
>
>
> >-----Original Message-----
> >Hi,
> >
> >I want to determine which key was pressed in a control,
> >like a datagrid. I see that in the currentcellchanged
> >event of a datagrid I can capture keystroke events. I
> >have tried someting like the following:
> >
> >Dim ky As New KeyPressEventArgs(Convert.ToChar(27))
> >
> >but this sets ky to the Escape key. I really want to
> >capture the number that goes in Convert.ToChar(...). How
> >can I capture that value?
> >
> >Thanks,
> >Steve
> >.
> >



 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      3rd Mar 2004
I'm sorry. I should have stated Key events. I have also
tried keydown/up evnts. But I only seem to capture/raise
these events for the Enter key. I would like to
capture/raise the key events for the arrow up/down keys.
Right now I am exploring creating/adding a custom event
handler to the form for this.

Dim Event CustomEvent

Sub Form_Load...

AddHandler Me.CustomEvent, AddressOf CustomEventHandler
....
End Sub

Sub TestEvent()
RaiseEvent Me.CustomEvent
End Sub
Sub CustomEventHandler(...)
Debug.Writeline("Event Trapped")
End Sub

But how do I pass keystrokes to my custom event handler?


>-----Original Message-----
>Hi Steve,
>
>Try using the KeyDown or KeyUp event. They have a broader

range of keys,
>including Up and Down arrows.
>
>Hope this helps
>Vikas
>
>"Steve" <(E-Mail Removed)> wrote in

message
>news:656601c40158$7ec27700$(E-Mail Removed)...
>> What I really want to do is to raise the KeyPress event

of
>> the Form or this datagrid control using the up or down
>> arrow keys. I have set the Form KeyPreview property to
>> true. The only key that seems to raise any Key events

is
>> the Enter key. Is there any way to raise a Key event
>> witht the arrow keys?
>>
>>
>> >-----Original Message-----
>> >Hi,
>> >
>> >I want to determine which key was pressed in a control,
>> >like a datagrid. I see that in the currentcellchanged
>> >event of a datagrid I can capture keystroke events. I
>> >have tried someting like the following:
>> >
>> >Dim ky As New KeyPressEventArgs(Convert.ToChar(27))
>> >
>> >but this sets ky to the Escape key. I really want to
>> >capture the number that goes in Convert.ToChar(...).

How
>> >can I capture that value?
>> >
>> >Thanks,
>> >Steve
>> >.
>> >

>
>
>.
>

 
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
Determine when Enter Key is pressed in a sheet?? Subodh Microsoft Excel Programming 2 12th Mar 2010 07:00 PM
How do I determine what key was pressed =?Utf-8?B?bm90c28=?= Microsoft Excel Programming 0 7th Apr 2007 06:04 PM
Determine Which Button Pressed =?Utf-8?B?TWlrZSBDb2xsaW5z?= Microsoft ASP .NET 14 23rd Aug 2006 02:36 PM
In LostFocus sub, can I determine which button was pressed? =?Utf-8?B?TWFyayBQYXJlbnQ=?= Microsoft Access Form Coding 1 10th May 2006 08:38 PM
How can you determine if the Laptop Fn key is pressed? =?Utf-8?B?c2NwYXJrZXI2Mg==?= Microsoft Dot NET Framework Forms 0 5th Jan 2005 06:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:49 AM.