按钮和键盘按下 [英] Buttons and keyboard presses

查看:68
本文介绍了按钮和键盘按下的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个简单的表单,用作键盘,按键1到9和零。

我想让按钮在任何当前选中的文本框中输入数字。



例如



如果我有5个不同的文本框,我的光标正在选择我想要的第四个单击bumber 5的按钮并将该号码放入所选的文本框中



任何人都可以帮我一些简单的示例代码吗?



我正在使用Visual Studio 2010并以windows形式开发



我在这方面非常新,所以越简单就越好。



谢谢

I am trying to write a simple form that serves as a keypad which has buttons 1 to 9 and zero.
I want to make the button enter the number into any currently selected text box.

For example

If I have 5 different text boxes and my cursor is selecting the forth one I want to click the button for bumber 5 and get that number put in the selected textbox

Can anyone help me with some simple sample code?

I am working Visual Studio 2010 and developing in windows form

I am very new at this so the simpler the better.

Thank you

推荐答案

按照以下步骤:

1)设计表格将有9个键像num pad

2)on button按下每个按钮的事件就在代码下面

Follow below step :
1) Design form which will have 9 keys like num pad
2) on Button click event of each button right below code
SendKeys.Send("A") // Note : Replace "A" with respective button value



假设单击事件1按钮写下面的代码


Suppose on click event of "1" button write below code

SendKeys.Send("1") // Note : Replace "A" with respective button value



3)阅读以下博客以获取更多信息



http://social.msdn。 microsoft.com/Forums/en-ZA/csharplanguage/thread/a01652a5-6fc3-43ce-92dd-fc0d105d47a3 [ ^ ]



接受如果作品另有回复则投票

--RDB


3) Read below blog for more information

http://social.msdn.microsoft.com/Forums/en-ZA/csharplanguage/thread/a01652a5-6fc3-43ce-92dd-fc0d105d47a3[^]

Accept and vote if works otherwise revert back
--RDB


这篇关于按钮和键盘按下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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