473,397 Members | 1,960 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,397 software developers and data experts.

How do Alt O on OK button

How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?

Nov 20 '05 #1
10 1756
Woody,
How do I fix it so that when the user presses Alt-X a certain button on the form gets fired? If your form has a menu, you can add hidden menu items that use the Alt-X as
a short cut. Although they are hidden the MenuItem.Click event will still be
raised.

Alternatively if your button has X in the label, you can prefix the X with a
& making the X underscored when displayed. Then when your run the

For example if I set the btnExit.Text property to "E&xit", I can use Alt-X
to click that button.
Also, How do I fix it so that when the esc key is pressed, the form is
closed?
Set the Form.CancelButton property to the button that has Me.Close in its
click event. Alternatively if you set the Button.DialogResult for this
control to DialogResult.Cancel, you do not need to handle the event, the
form will close. (I do this for forms that I use Form.ShowDialog on, I have
not tested with forms I use Form.Show on).

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl... How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?

Nov 20 '05 #2
Change your caption so that a & is right before the HotKey. For example

&OK will make Alt-O fire the button, E&xit will make Alt-X fire the button.

"Woody Splawn" <wo***@splawns.com> wrote in message news:uM*************@tk2msftngp13.phx.gbl...
How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?

Nov 20 '05 #3
Hi Woody, in the text of your button, does the letter 'x' appear? If so, you
can prefix 'x' with an ampersand (&):

Text = "E&xit"

The X will appear underlined (unless your using Windows 2000/2003/XP with
the underlining turned off until Alt is pressed), and will respond to Alt+X

Also, if you set the KeyPreview property of your form to True, then you can
trap the Escape key in the KeyPress event of the form.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Woody Splawn" <wo***@splawns.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?

Nov 20 '05 #4
"Woody Splawn" <wo***@splawns.com> scripsit:
How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?
In the button's 'Text' property you can specify a mnemonic by putting
the "&" character in front of it: "Cli&X".
Also, How do I fix it so that when the esc key is pressed, the form is
closed?


Set the form's 'CancelButton' property to a button. Then set the
button's 'DialogResult' property.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #5

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:uh**************@tk2msftngp13.phx.gbl...
Set the Form.CancelButton property to the button that has Me.Close in its
click event. Alternatively if you set the Button.DialogResult for this
control to DialogResult.Cancel, you do not need to handle the event, the
form will close. (I do this for forms that I use Form.ShowDialog on, I have
not tested with forms I use Form.Show on).
It doesnt seem to work if the form is not shown with ShowDialog. For example, if the form is the
startup form, this will not cause ESC to close it. However, if you set the Forms CancelButton
property, it seems that the ESC key will fire the event of the button specified, no matter how the
form is shown.

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
How do I fix it so that when the user preses Alt-X a certain button on the
form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?


Nov 20 '05 #6
Rick,
Thanks for confirming that. I normally do not allow Esc to close the main
form just Dialog boxes. I use ShowDialog on Dialog boxes.

Thanks again
Jay
"Rick Mogstad" <ri**@NOSPAM.computetosuit.com> wrote in message
news:ei*************@TK2MSFTNGP09.phx.gbl...

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message news:uh**************@tk2msftngp13.phx.gbl...
Set the Form.CancelButton property to the button that has Me.Close in its click event. Alternatively if you set the Button.DialogResult for this
control to DialogResult.Cancel, you do not need to handle the event, the
form will close. (I do this for forms that I use Form.ShowDialog on, I have not tested with forms I use Form.Show on).
It doesnt seem to work if the form is not shown with ShowDialog. For

example, if the form is the startup form, this will not cause ESC to close it. However, if you set the Forms CancelButton property, it seems that the ESC key will fire the event of the button specified, no matter how the form is shown.

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
How do I fix it so that when the user preses Alt-X a certain button on the form gets fired?

Also, How do I fix it so that when the esc key is pressed, the form is
closed?



Nov 20 '05 #7
A bit off topic, but did you notice that ShowDialog (Modal in VB6) will allow the form to be shown
in the taskbar while its modal? It didnt do that in VB6 without some subclassing.

A nice feature.

Rick
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Rick,
Thanks for confirming that. I normally do not allow Esc to close the main
form just Dialog boxes. I use ShowDialog on Dialog boxes.

Thanks again
Jay
"Rick Mogstad" <ri**@NOSPAM.computetosuit.com> wrote in message
news:ei*************@TK2MSFTNGP09.phx.gbl...

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in

message
news:uh**************@tk2msftngp13.phx.gbl...
Set the Form.CancelButton property to the button that has Me.Close in its click event. Alternatively if you set the Button.DialogResult for this
control to DialogResult.Cancel, you do not need to handle the event, the
form will close. (I do this for forms that I use Form.ShowDialog on, I have not tested with forms I use Form.Show on).


It doesnt seem to work if the form is not shown with ShowDialog. For

example, if the form is the
startup form, this will not cause ESC to close it. However, if you set

the Forms CancelButton
property, it seems that the ESC key will fire the event of the button

specified, no matter how the
form is shown.

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uM*************@tk2msftngp13.phx.gbl...
> How do I fix it so that when the user preses Alt-X a certain button on the > form gets fired?
>
> Also, How do I fix it so that when the esc key is pressed, the form is
> closed?
>
>
>



Nov 20 '05 #8
>Alternatively if your button has X in the label, you can prefix the X with
a
& making the X underscored when displayed. Then when your run the For example if I set the btnExit.Text property to "E&xit", I can use Alt-X
to click that button.


Thank you.

I tried this in design mode in the properties for the button and this works
but with one catch. The first time I bring the form to the screen I do not
see the underbars. If I press the button or type Alt-X they show but they
do not show when the form is first brought to the screen. I call the dialog
with the following syntax:

iResult = DLG.ShowDialog(Me)



Nov 20 '05 #9
Woody,
Its a 'feature' of Windows XP (I am not certain about Windows 2000, I want
to say it has the same 'feature').

The underscore is not displayed until you press Alt, same with the menus.

In Windows XP you can control the option under "Display Properties -
Appearance - Effects - Hide underlined letters for keyboard navigation until
I press the Alt key"

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
Alternatively if your button has X in the label, you can prefix the X with
a
& making the X underscored when displayed. Then when your run the
For example if I set the btnExit.Text property to "E&xit", I can use

Alt-Xto click that button.


Thank you.

I tried this in design mode in the properties for the button and this

works but with one catch. The first time I bring the form to the screen I do not see the underbars. If I press the button or type Alt-X they show but they
do not show when the form is first brought to the screen. I call the dialog with the following syntax:

iResult = DLG.ShowDialog(Me)


Nov 20 '05 #10
Hi Jay, It's the same with Windows 2000.

--
HTH,
-- Tom Spink, Über Geek

Please respond to the newsgroup,
so all can benefit

" System.Reflection Master "

==== Converting to 2002 ====
Remove inline declarations
"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> wrote in message
news:#T**************@TK2MSFTNGP10.phx.gbl...
Woody,
Its a 'feature' of Windows XP (I am not certain about Windows 2000, I want
to say it has the same 'feature').

The underscore is not displayed until you press Alt, same with the menus.

In Windows XP you can control the option under "Display Properties -
Appearance - Effects - Hide underlined letters for keyboard navigation until I press the Alt key"

Hope this helps
Jay

"Woody Splawn" <wo***@splawns.com> wrote in message
news:uN**************@TK2MSFTNGP12.phx.gbl...
Alternatively if your button has X in the label, you can prefix the X with
a
& making the X underscored when displayed. Then when your run the

For example if I set the btnExit.Text property to "E&xit", I can use Alt-Xto click that button.


Thank you.

I tried this in design mode in the properties for the button and this

works
but with one catch. The first time I bring the form to the screen I do

not
see the underbars. If I press the button or type Alt-X they show but

they do not show when the form is first brought to the screen. I call the

dialog
with the following syntax:

iResult = DLG.ShowDialog(Me)



Nov 20 '05 #11

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

Similar topics

6
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a...
25
by: KK | last post by:
Hi, I am using history.go(-1) for implementing the back button functionality. Its working fine but with this exception. 1. The page which is having back button has some hyperlinks on it. ...
3
by: Zürcher See | last post by:
Someone has implemented a Datagrid Button for the Windows.Form?
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.