How to add a shortcut Ctrl+S ?

  • Thread starter Thread starter cyshao
  • Start date Start date
C

cyshao

How to add a shortcut Ctrl+S ?

I want to add a new function for user to provide Ctrl+S to save things.
How can I do that?

Thanks

Charles Shao^_^
 
Create a menu item "Save" under the appropriate mainmenu item such as "File".
In the design-view, click on this "Save" menu item. In the Properties window,
change the value of ShowShortcut to "True". Now, in the same properties
window, click on the property "Shortcut". In the right-side column, a small
button with a down-arrow appears. Click on that button, and from the options
offered, select "CtrlS" option. Now, in the event-handler for the said menu
item, put the neccesary code for the Save functionality. Build your
application. Now, you can use the Ctrl + S keys to directly save your
document.
 
Thank you.

But it's a dailog form without menu.
How can I do this ?
 
Add the following code to your form to capture Ctrl + S:

private void <your_form>_KeyDown(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.S && e.Control)
MessageBox.Show("Ctrl+S pressed");
}

Gabriel Lozano-Morán
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top