我想在textbox重判断只允许输入数字和冒号,且第一个不允许为冒号该怎么实现
解决方案 »
- 事件订阅不上的问题
- DataGridView.HeaderCell.ContextMenuStrip怎样获取右键点击了哪一列??
- 用WebClient方法登录一个网页,老出错,请指教
- 问个问题啊 在C#中 怎么读取EXECL 中的数据 写导入工具 没写过 大家 谢谢 了啊
- 求限制字数的正则表达式
- 100分,解决了再贴帖另加100分,觉不食言
- 安装sql2005与vs2010
- c#怎么匹配出里面的值如SoilType和rosebegintime麻烦给个例子 谢谢
- 安装程序制作
- 问几个常见的WinForm编程问题,需要点技巧.
- 菜鸟问题又来了,VS2005(08)中如何使用向导对话框
- 求一正则 【非负整数和非负浮点数】
{
Regex r = new Regex(@ "^\d*$|\:");
if (!r.IsMatch(this.textBox1.Text))
{
textBox1.Text=s;//恢复
textBox1.SelectionStart = s.Length;
}
else
s=textBox1.Text;
}
if (!r.IsMatch(this.textBox1.Text))
{
textBox1.Text=s;//恢复
textBox1.SelectionStart = s.Length;
}
else
s=textBox1.Text;
{
if ((e.KeyChar >= '0' && e.KeyChar <= '9') || e.KeyChar == 8)
{ e.Handled = false;
}
else if (e.KeyChar == 58)
{
if (textBox1.Text.Length > 0)
{
e.Handled = false;
}
else
{
e.Handled = true;
}
}
else
{
e.Handled = true;
}
}
if (textBox1.Text != ":")
{
Regex r = new Regex(@"^\d*$|\:");
if (!r.IsMatch(this.textBox1.Text))
{
textBox1.Text = s;//恢复
textBox1.SelectionStart = s.Length;
}
else
s = textBox1.Text;
}
else
{
textBox1.Text=s;
}
private void textBox4_KeyPress(object sender, KeyPressEventArgs e)
{
if (e.KeyChar==':')
{
e.Handled = true;
}
}数字字母同样实现的方式很多
哪不对了,写在KeyPress事件中