using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows;
namespace WindowsFormsApplication2
{
public partial class Form1 : Form
{
public Form1()
{
// Create a TextBox control.
TextBox tb = new TextBox();
this.Controls.Add(tb);
//將此改為windows視窗物件
//https://msdn.microsoft.com/zh-tw/library/system.windows.window(v=vs.110).aspx
tb.KeyPress += new KeyPressEventHandler(keypressed);
}
private void keypressed(Object o, KeyPressEventArgs e)
{
//判斷按鍵的 Keychar
char Key_Char = e.KeyChar;
MessageBox.Show(((int)(Key_Char)).ToString());
}
}
}
沒有留言:
張貼留言