如何让一个TextBox控件只接受货币数字? C#中不能用正则表达式,VB是可以的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 KillCat你的Regex.Match是什么意思,看不懂。Vs.Net中help连你写的关键字都查不到,是否是简写,拜托写清楚些好吗?不胜感激!!! private void textBox1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { switch(e.KeyChar) { case '$': { if(((TextBox)sender).Text.Length > 0) { e.Handled = true; } break; } case '.': { if(((TextBox)sender).Text.IndexOf(".") > 0) { e.Handled = true; } break; } case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '0': { break; } default: { e.Handled = true; break; } }//switch } switch (Style) { case uTextBox_style.Numeric: string strSymbol="-+."; if ((Char.IsDigit(e.KeyChar)) | (Char.IsControl(e.KeyChar)) | (strSymbol.IndexOf(e.KeyChar.ToString())!=-1)) { } else { e.Handled=true; } break; } FindProxyForURL很慢。有什么解决的方案? 【在线等求解】dataGridView从数据库读表 判断如果课程等于1 Cells[4] 显示语文 出错…… 提示输入字符不正确 向高手请教gridview控件问题 请教数组查重复 wiki编辑器移植问题 c#打包的时候如何设置序列号! 请看一下这个错误,谢谢各位。数据库读取出来信息之后报错 关于MDI窗口与子窗口的问题` 编译出错! C#的一个基础问题 C#:web页面上如何实现类同于WINDOWS FORM的openfiledialog功能? this操作数的作用,在线急等
{
switch(e.KeyChar)
{
case '$':
{
if(((TextBox)sender).Text.Length > 0)
{
e.Handled = true;
} break;
}
case '.':
{
if(((TextBox)sender).Text.IndexOf(".") > 0)
{
e.Handled = true;
} break;
}
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
case '0':
{
break;
}
default:
{
e.Handled = true;
break;
}
}//switch
}
{
case uTextBox_style.Numeric:
string strSymbol="-+.";
if ((Char.IsDigit(e.KeyChar)) | (Char.IsControl(e.KeyChar)) | (strSymbol.IndexOf(e.KeyChar.ToString())!=-1))
{
}
else
{
e.Handled=true;
}
break;
}