473,804 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to handle the CTRL+A keys?

I’m using the DataGrid control. The DataGrid allow select all by clicking on
CTRL+A keys.
I need to catch this keys event, so I tried using the KeyDown event, but
only when the CTRL is pressed I get the event, but if the A key is pressed
while the CTRL is pressed – The event is not fired to my KeyDown handler.

How do I get the event for the CTRL + A keys?
---------
Thanks
Sharon
Dec 22 '05 #1
5 27394
Hi Sharon,

You cannot catch the ctrl+A event in the DataGrid level because it was
fired inside the TextBox of the cell. So in this case, you have to handle
the TextBox.KeyDown events to catch this or, you can use sub-class the
DataGrid to achieve this. Here is a thread similar to your requirements. I
think it will be helpful to you.

http://groups.google.com/group/micro...rk.windowsform
s.controls/browse_frm/thread/9f53c61f3e729ce b/bcdc1ec769d30da 1?lnk=st&q=%22J
effrey+Tan%22+d atagrid+process cmdkey&rnum=1&h l=zh-CN#bcdc1ec769d3 0da1

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 22 '05 #2
Hey Sharon, if you're using the KeyDown event try this.

private void yourKeyDownEven t(object sender, KeyEventArgs e)
{
if(e.Control && e.Equals(Keys.A ))
{
// your code here
}
}

Dec 22 '05 #3
Thanks for try Justin,
But when the CTRL key is pressed down --> the event is fired, but the A key
event is not firing the event because the CTRL key is still pressed.

I event changed the code to:
private void OnDataGridKeyDo wn(object sender,
System.Windows. Forms.KeyEventA rgs e)
{
if( e.Equals(Keys.A ) )
{
if( e.Control ) // It never gets in here !!!
{
// Some code...
}
}
}

I hope there is a solution for that.

------
Thanks
Sharon
Dec 22 '05 #4
Hey Sharon, sorry about that, I thought I saw it work but I'm doing it
now and it's not working.

I did some code awhile ago to do something like this but I can't seem
to find it. What you have to do is override some system commands
because you won't be able to use KeyDown or KeyPress. Once the control
key is it, pressing another key will not fire the keyDown event. I'll
look around some more, but for now I would focus on looking for the
lower level functions that get called when system keys (control, alt,
shift, etc.) are pressed. I'll post again if I find what I'm talking
about. good luck

Dec 22 '05 #5
On Thu, 22 Dec 2005 06:59:04 -0800, Sharon <Sh*****@newsgr oups.nospam>
wrote:
Thanks for try Justin,
But when the CTRL key is pressed down --> the event is fired, but the A key
event is not firing the event because the CTRL key is still pressed.

I event changed the code to:
private void OnDataGridKeyDo wn(object sender,
System.Windows .Forms.KeyEvent Args e)
{
if( e.Equals(Keys.A ) )
{
if( e.Control ) // It never gets in here !!!
{
// Some code...
}
}
}

I hope there is a solution for that.

------
Thanks
Sharon


Try overriding the ProcessDialogKe y event:

bool ProcessDialogKe y(Keys keyData)

For Ctrl-A use
if (keyData == Keys.Control | Keys.A) ...
or else
switch (keyData) { case Keys.Control | Keys.A: ...

Return true if you have processed the key, otherwise return
base.ProcessDia logKey(keyData) to give the rest of the system access
to the keystrokes you are not handling.

rossum

--

The ultimate truth is that there is no ultimate truth
Dec 28 '05 #6

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

Similar topics

1
1666
by: Sylwia | last post by:
Hi! I'm writing an application that runs in a 'Full screen' mode. I do not want any other windows (as well as the desktop) to be accessible while my application is running. My problem is that when I press for example a key 'Windows left logo' (with keyboard scan code 91) my app looses focus and Windows menu 'Start' opens.
3
23278
by: Coder | last post by:
hi, there is still no answer, i wonder if there is a way to handle the multiple key-press event on a C# windows form, like "Ctrl+Enter"
3
3149
by: Mark | last post by:
Any Visual C++ source code available for disabling the following keys in windows 2000. Alt + Ctrl + Del Ctrl + Esc Windows Key to Remove task bar Function keys (or Alt + Function keys or Ctrl + function keys) disabling the Right mouse
9
3027
by: Miky | last post by:
Hi, I need to send Ctrl-PgUp (or Ctrl-PgDown) to the active application but when I use SendKeys.Send("^{PGUP}"), the program understands it as just PageUp. How may I solve it? Thanks in advance, LDV-ME.
3
3131
by: Pooja | last post by:
Hi guys, I have been struggling with this problem for quite a sometime now. Before a state down my problem wanna give an exmaple: 1. Open a MsWord document. 2. Open the Page Setup dialog box. 3. Navigate using the tab key in the entire dialog box. Use Ctrl+Tab to navigate between the tab page.
1
2917
by: Emma Middlebrook | last post by:
Hi there, I'm trying to handle some shortcut keys within my application and I can't seem to get the code to work when you are trying to action against a ctrl + other character. I found a post http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/a0bfd442d01f715f/27cbc8062c107680?lnk=gst&q=c%23+shortcut+key+ctrl&rnum=3&hl=en#27cbc8062c107680 that appears to help a lot but it doesn't seem to work...
1
3067
by: phcmi | last post by:
Within a mousedown event, can you please show a code sample of how to ascertain whether the CTRL and/or ALT and/or SHIFT keyboard key is pressed? Thank you
2
3325
by: Charles Law | last post by:
I'll kick myself when you tell me, but ... I have a user control on a form, and I want the user control to see the arrow keys when I press them. If I press just about any other key the control's KeyDown event is fired, but not when I press a direction key. I want to see them in the KeyDown event so that I can respond as soon as the key is depressed, and I want to detect when the key is held down so that I can perform an action...
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10351
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.