启用ctrl + S作为保存按钮的快捷方式 [英] Enable ctrl+S as a short cut for save button

查看:94
本文介绍了启用ctrl + S作为保存按钮的快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的代码是:

my code is :

'Private Sub ExpenseMaster_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

 '    If (e.KeyCode = Keys.S && e.Control) Then


   '        Save.PerformClick()
   '    End If
   '
   'End Sub


帮助我了解如何在vb.net中启用ctrl + s?

我还尝试了SendKeys.Send(^ {s})来启用快捷方式.
请帮帮我.


Help me out how to enable ctrl + s in vb.net?

I have also tried SendKeys.Send(^{s}) to get short cut enabled.
Please help me out.

推荐答案

这对我有用.

请原谅代码风格,我不习惯VB.Net

This works for me.

Excuse the code style please, I''m not used to VB.Net

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    MessageBox.Show("Save Called")
End Sub
Private Sub Button1_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown
    If e.Control Then
        If e.KeyCode = Keys.S Then
            Button1.PerformClick()
        End If
    End If
End Sub



我刚刚注意到您想要一个小写的"s",因此请适当修改我的代码.



I have just noticed that you want a lower case ''s'', so modify my code appropriately.


在页面加载中添加以下代码

add below code in page load

Me.KeyPreview = True


这篇关于启用ctrl + S作为保存按钮的快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆