?
Solved

Newbie question- use F10 to make save happen

Posted on 2005-05-13
3
Medium Priority
?
251 Views
Last Modified: 2010-05-18
I have a simple form, that has a save button.

I would like the "F10" key to be able to Save as well.  

Any help greatly appreciated.
td
0
Comment
Question by:down0041
3 Comments
 
LVL 13

Assisted Solution

by:softplus
softplus earned 100 total points
ID: 14000402
The easiest way would be to use a menu, just define a Shortcut for the menu item (F10)

The harder way would be to handle the Keydown-events for the form, i.e.
    Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
        If e.KeyData = Keys.F10 Then
            ' do whatever
            e.Handled = True
        End If
    End Sub
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 100 total points
ID: 14000606
Another way via ProcessCmdKey()...

Public Class Form1
    Inherits System.Windows.Forms.Form

    Protected Overrides Function ProcessCmdKey(ByRef msg As System.Windows.Forms.Message, ByVal keyData As System.Windows.Forms.Keys) As Boolean
        If (msg.WParam.ToInt32 = Keys.F10) Then
            ButtonSave_Click(Nothing, Nothing)
            Return True
        End If
        Return False
    End Function

    Private Sub ButtonSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonSave.Click
        MsgBox("Simulated Save...")
    End Sub

End Class
0
 

Author Comment

by:down0041
ID: 14028430
Thank you.  This is exactly what I needed.  
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question