using System;
using System.Windows.Forms;
namespace AtTongxilai
{
/// <summary>
/// 只能输入数字的文本框
/// </summary>
public class NumTextBox : TextBox
{
public NumTextBox()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
protected override void WndProc(ref System.Windows.Forms.Message m)
{
int WM_CHAR = 0x0102;
if(m.Msg == WM_CHAR)
{
if(((char)m.WParam >= '0') && ((char)m.WParam <= '9') ||
(int)m.WParam == (int)Keys.Back || (int)m.WParam == (int)Keys.Delete)
{
base.WndProc (ref m);
}
}
else
{
base.WndProc (ref m);
}
}
}
}