473,394 Members | 1,663 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.

Shortcut Key question (i.e. "&Submit")

rh
I have a Button on a WinForm that has a text property = "&Submit".

I noticed that whenever I pressed the "S" key only (without pressing the
"Alt" key) the Button's click event would fire. I thought that it was only
supposed to fire if the combo "Alt+S" was pressed.

My problem is that I have another control (a DataGrid) that is suppoed to
respond to the "S" key being pressed and I don't want the Button's click
event to be fired. I only want it to be fired if the combo "Alt+S" is
pressed.

Any suggestions?
Nov 16 '05 #1
3 1928
"rh" <rh******@smci.com> schrieb:
I have a Button on a WinForm that has a text property = "&Submit".

I noticed that whenever I pressed the "S" key only (without pressing the
"Alt" key) the Button's click event would fire. I thought that it was only
supposed to fire if the combo "Alt+S" was pressed.

The button's 'Click' event is fired by pressing the S key if a control that
doesn't expect user input (like a button, for example) has focus. Alt+S
will work too if a textbox has the input focus.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 16 '05 #2
"rh" <rh******@smci.com> wrote:
I noticed that whenever I pressed the "S" key only
(without pressing the "Alt" key) the Button's click
event would fire. I thought that it was only supposed
to fire if the combo "Alt+S" was pressed.
No, that behaviour is standard (depending on what already has the
focus).
I only want it to be fired if the combo "Alt+S" is
pressed.


You can test Control.ModifierKeys in the Button's Click event code,
and do something different if the Alt key is being pressed.
Alternatively, set the Form's KeyPreview to true, and you can deal
with keystrokes at form level instead of control level.

P.
Nov 16 '05 #3
yyy
I did something like this to ensure that Alt and S are both pressed:
private void Key_Down(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.Alt) {
if(e.KeyCode == Keys.s)
{
//1st button is clicked
}
}
if(e.KeyCode == Keys.s)
{
//2nd button is clicked
}
}
*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 16 '05 #4

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

Similar topics

27
by: aa | last post by:
Thought this question might be out of this NG's scope, there are always knowledgable people who might hava an answer. A hyperlink to a shortcut to a file returnes an empty screen, and the source...
10
by: Lex | last post by:
I am writing a C# app that has a Menu. Some of the menu items will have short cuts that do not exist in the Shortcut enum. I would like the custom shortcuts to appear on the menu but as far as I...
4
by: Salad | last post by:
A97. If you set a forms properties to ShortcutMenu = No, the entire form is disabled from displaying a shortcut menu. If you set the property to Yes, all controls have a shortcut menu. I have...
5
by: Steven | last post by:
I have some text boxes on a form in MS Access 2000. When I right click in them I don't get any shortcut menu at all. I want the normal cut, copy, and past menu to come up. In the "Startup", I...
0
by: cefrancke | last post by:
I recently discovered, that if you set the startup options for "security", you will have alot of work do to get Access back to "normal". If you disable the built-in menus/toolbars you'll have to...
0
by: Marcel | last post by:
Hi, the application I am writing has a MainMenu and a DataGrid (UltraGrid). Now I have to edit the text of each cell in this grid. So far so good. All works fine in editmode but if I press a...
4
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create...
3
by: TC | last post by:
I've written an application using VB.NET 2003 and packaged it with a deployment project. When I use the setup program to install the application, however, it doesn't work. More specifically, the...
7
by: GrandpaB | last post by:
I would appreciate assistance learning how to create a Desktop shortcut in my setup project. In the left pane of the Setup/File System window I right-clicked User's Desktop. From the contex...
5
by: remya1000 | last post by:
i'm using VB.NET 2003 application program. by using OpenFileDialog, we can select the file name or file path. OpenFileDialog1.ShowDialog() pgmPath.Text =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.