PDA

View Full Version : Assign sortcut keys


hytechpro
04-18-2006, 07:20 AM
Hello friends,

How can i assign sortcut keys to buttons which are on a form in C# (http://www.hytechpro.com)for example i have a form on it there are two buttons when i run this form i wanna use "p" key to provide the functionality of Print button and also "D" key press for another purpose i wanna use.Anybody can help.I am waiting your replay.

Thanks:
Dev

Melon00
04-18-2006, 05:20 PM
I am assuming you want to create "hotkeys." You have a print button that says "Print" on it, so just put an ampersand in front of the P in the text string. Changing it to look like this:

this.printButton.Text = "&Print";

If you want a shortcut key like ctrl-P, that is something different. You would use this instead:

this.printButton.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.P)));