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

assigning function keys to toolstripbutton

Hello,

Is it possible to assign a function key to a toolstripbutton? I don't
see the property for such an action in the properties for the
tsButton.

I have a "new" button on the toolstrip. I'd like F2 to fire the click
event handler. Is this possible?

Thanks!
Jun 27 '08 #1
2 9150
On Tue, 03 Jun 2008 22:26:04 -0700, Adam Sandler <co****@excite.comwrote:
Hello,

Is it possible to assign a function key to a toolstripbutton? I don't
see the property for such an action in the properties for the
tsButton.
If you are displaying text with the button, the button can have an
accelerator key shortcut, which you can specify by preceding the
appropriate letter in the text of the button with an ampersand.

If not, then as far as I know, you'd have to handle the keyboard input
elsewhere (such as the form's keyboard input methods) and map it to the
same action as the button (or just call PerformClick() method on the
button).

Pete
Jun 27 '08 #2
On Jun 4, 12:00 am, "Peter Duniho" <NpOeStPe...@nnowslpianmk.com>
wrote:
>
If you are displaying text with the button, the button can have an
accelerator key shortcut, which you can specify by preceding the
appropriate letter in the text of the button with an ampersand.

If not, then as far as I know, you'd have to handle the keyboard input
elsewhere (such as the form's keyboard input methods) and map it to the
same action as the button (or just call PerformClick() method on the
button).

Pete
Yep... if one isn't using an accelerator key, which can very well
happen on buttons with graphics only, then the handler needs to be
assigned to the form.

I did some more searching and found this link: http://support.microsoft.com/kb/839201

And here is some pared down code based upon the MS example:

private void Form1_Load(object sender, System.EventArgs e)
{
this.KeyDown += new
System.Windows.Forms.KeyEventHandler(this.Form1_Ke yDown);
}

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.F2)
{
MessageBox.Show("F2 pressed");
}
if (e.Control && e.KeyCode == Keys.P)
{
MessageBox.Show("print clicked");
}
}
Jun 27 '08 #3

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

Similar topics

1
by: Don W. | last post by:
I need to use some function keys as speed-keys (instead of clicking a button with the mouse.) Using this code doesn't display any codes for the function keys: <html><body> <SCRIPT...
3
by: Armando | last post by:
Apologies if this has been covered recently - I lurked and saw nothing. I have an application that does ticketing at a three-screen movie theatre, and I'm using the function keys F1 thru F12...
3
by: Dennis C. Drumm | last post by:
What is the best way for a modal dialog (windows form) to invoke an unpublicized key combination such as CTRL-ALT-F6? Would it be to set a single key up event for all the controls in the dialog to...
4
by: One | last post by:
hi.. how to get function keys(F1 to F12) when they are pressed? Thankx
4
by: Broeisi | last post by:
Hello, I'm trying to write a console based program in C in Linux. I want to use the function keys in my program, but I don;t know how to let the C program know when for exmaple the F1 key is...
1
by: Sam Samson | last post by:
Greeetings All .. For my users convenience I have mapped function keys F2 .. F12 to change the tabs on the Tabcontrol. Works like a charm <ominous musicuntil one hits F8</ominous music> ...
1
by: simiCop | last post by:
I'm writing a computer aided dispatching program targeted at security companies. While within certain text box fields, I want to assign the Function keys (F2, F6, etc.) to trigger a search, exit,...
9
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.