虚拟键盘
Form1上放一個TextBox1,及建立一Form2的instance。
private Form2 f2 = new Form2();
在TextBox1的Enter事件中,將Form2顯示出來!
f2.Show(this);
Form2上放一個Button1
在Button1的Click事件中將Focus回到Form1,並SendKey(假設我送的是數字1)回到Form1上,
this.Owner.Focus();
SendKeys.Send("{1}");
Form1.cs
public partial class Form1 : Form { private Form2 f2 = new Form2(); public Form1() { InitializeComponent(); } private void textBox1_Enter(object sender, EventArgs e) { f2.Show(this); } }
Form2.cs
public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { this.Owner.Focus(); SendKeys.Send("{1}"); } }