111,119
社区成员
发帖
与我相关
我的任务
分享
static bool IsNumeric(string str)
{
System.Text.RegularExpressions.Regex reg1
= new System.Text.RegularExpressions.Regex(@"^[-]?d+[.]?d*$");
return reg1.IsMatch(str);
}
using System.Runtime.InteropServices;
[DllImport("User32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("User32.dll")]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
public const int GWL_STYLE = -16;
public const int ES_NUMBER = 0x2000;
private void Form1_Load(object sender, EventArgs e)
{
SetWindowLong(textBox1.Handle, GWL_STYLE,
GetWindowLong(textBox1.Handle, GWL_STYLE) | ES_NUMBER);
}