我如何使用按钮运行两个键为(ctrl + p) [英] how can I run two key as (ctrl+p) using button

查看:179
本文介绍了我如何使用按钮运行两个键为(ctrl + p)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用按钮

推荐答案

,以(ctrl + p)的形式运行两个键?您可能想查看静态SendKeys类的Send()方法.阅读此 http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx [

好的,所以我从来没有尝试过,并以为我会尝试一下,所以这就是我所做的.

首先,我在按钮2 click事件处理程序中的表单中添加了两个按钮
You may want to check out the Send() method of the static SendKeys class. Read this http://msdn.microsoft.com/en-us/library/system.windows.forms.sendkeys.send.aspx[^]

to send Ctrl+P you would do SendKeys.Send("^P");


Ok so I have never tried this and thought I would give it a go so here is what I did.

First I added two buttons to the form in button 2 click event handler I put
MessageBox.Show("Hello!");


在按钮1中,我放置了事件处理程序


in button 1 click event handler I put

button2.Focus();
SendKeys.Send("{ENTER}");


此代码触发了button1的button2 click事件

第二次,我在按钮单击事件处理程序中使用了两个文本框和一个按钮


this code fired button2 click event from button1

Second time I used two text boxes and a button in the button click event handler I put

textBox1.Text = "Sheep Goat Pig";
textBox1.Focus();
SendKeys.Send("^C"); //copy
textBox2.Focus();
SendKeys.Send("^V"); //paste


此代码从textBox1复制了文本并将其粘贴到textBox2

并且肯定两次都很好用!因此,尝试一下它可能是您想要的. :)


this code copied the text from textBox1 and pasted it into textBox2

and sure enough both times it worked great! So give it a try it may be what your looking for. :)


这篇关于我如何使用按钮运行两个键为(ctrl + p)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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