473,394 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

determine which key is pressed in control?

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
Nov 20 '05 #1
3 1667
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
.

Nov 20 '05 #2
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" <an*******@discussions.microsoft.com> wrote in message
news:65****************************@phx.gbl...
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
.

Nov 20 '05 #3
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" <an*******@discussions.microsoft.com> wrote in messagenews:65****************************@phx.gbl...
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
>.
>

.

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vern | last post by:
I have a custom control which has it's own OnValidating event handler. I would like to skip the validations if the Cancel/Exit button is pressed. Also, if possible, would like to skip the...
0
by: Vern | last post by:
I have a custom control which has it's own OnValidating event handler. I would like to skip the validations if the Cancel/Exit button is pressed. Also, if possible, would like to skip the...
1
by: mdb | last post by:
I want to determine whether the SHIFT key is depressed, but NOT during a key up/down/pressed event. How can I do that?
14
by: Mike Collins | last post by:
In my page initialize, I am loading dynamic controls for a survey. On the survey, I have a stop button. If the user clicks the stop button, because of the page life cycle, the initialize and page...
8
by: Joe | last post by:
Hi trying to write some code to determine if user has large/small fonts set on PC thought this would work but it didn't Any suggestions??? Thanks Graphics g = Graphics.FromHwnd(this.Handle);
3
by: =?Utf-8?B?cGFucGF3ZWw=?= | last post by:
Is there a way to quickly determine if the key pressed was from 'A'-'Z' or '0'-'9' range? I really don't like to write switch with every Keys.A, Keys.B, etc key listed Paul
8
by: Johannes Meng | last post by:
Good day, I'm experimenting with unbuffered input at the moment. To get input I basically use cin.get(). My problem are control sequences preceeded by an ESC character (i.e. up, down, f-keys et...
3
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
Is there any way to determine the state of the mouse buttons during a WM_NCHITTEST message? I have a situation where I need to perform custom logic during a WM_NCHITTEST messsage (by overriding a...
3
by: mmckinnon | last post by:
Hi All, This is really basic but I'm having trouble finding a straight forward way to do this. I have an Access application where the for is in spreadsheet mode. When a user leaves a control...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.