Click here to Skip to main content
15,897,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to set short key for button such as save,delete,update and so .how to set this in form so please give me suggestion.
Posted
Comments
smithjdst 26-Dec-13 5:41am    
Like a hot key or just when you press a specific sequence of Keys? Next question is by save/delete/update is this code that you have already programmed.

There is a easy way to do this by prepending "&".

Refer- Creating Access Keys for Windows Forms Controls[^]
Quote:
set the Text property to a string that includes an ampersand before the letter that will be the access key. For example, to set the letter "P" as the access key, type "&Print" into the grid.

Otherwise go through Building Keyboard Accelerators into .NET Windows Forms Applications[^], if you want to assign keys according to your requirements.
 
Share this answer
 
to create hot key there are 2 ways;-

1) by changing the text of your button with "&".Like if you have a button "Save" And want to create a hot key you can change the name by "&Save" that will create a hot ket (Alt + S).

2) by adding the hot key on Form_KeyDown event. Like
for save you want (Control + S) then write

if(e.Control == true && e.KeyData == Keys.S)
{
    btnSave_Click(sender,e);
}
 
Share this answer
 
goto properties of button and set "text" like &Save, so alt+s is sortkey of that button

&Delete is alt+D
Upda&te is alt+T
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900