关于输入字符串严正问题(验证ip) 就是给一个textbox做验证啊。输入如果输入的是非数字或“.”,则不让他输入。如果输入到3位数字就直接加个点。这是不是要求正则表达式的功力很深厚呢???请详细指教下好吗?越详细越好。谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx这个也许适合你 先定义个全局变量 public int _n=1; public int _nn=0; if(e.KeyChar>=48 && e.KeyChar <=57) { e.Handled =false; if(this.textBox1.TextLength % (3*_n + _nn)==0 ) { _n =_n+1; _nn =_nn+1; this.textBox1.Text =this.textBox1.Text + "."; this.textBox1.SelectionStart = this.textBox1.TextLength; } } 测试正确的:先定义个全局变量 public int _n=1; public int _nn=1; if(e.KeyChar>=48 && e.KeyChar <=57) { e.Handled =false; int i = this.textBox1.Text.Split('.').Length; _n = i; _nn=_n-1; if(this.textBox1.TextLength % (3*_n + _nn)==0 ) { this.textBox1.Text =this.textBox1.Text + "."; this.textBox1.SelectionStart = this.textBox1.TextLength; } } 在一个窗体内调用另一个窗体的函数为何会失败? 莫名其妙的数据库异常 C# 固定时间触发事件 C#中函数参数传递的问题 关于隐式转换为的问题。请高手帮忙解决。 C# listview 正常显示 如果获取datagrid中某行中某个字段的值 为什么winform中datagrid显示数据库datetime数据只显示日期不显示时间呢 enterprise library for .net 2.0的版本有谁会用。 在RichTextBox中,如何得到光标所在的行号和列号? session不允许第二次投票的代码 GridView中有“启用删除”。怎么编码,让它实现:弹出个确认对话框
这个也许适合你
public int _nn=0;
if(e.KeyChar>=48 && e.KeyChar <=57)
{
e.Handled =false;
if(this.textBox1.TextLength % (3*_n + _nn)==0 )
{
_n =_n+1;
_nn =_nn+1;
this.textBox1.Text =this.textBox1.Text + ".";
this.textBox1.SelectionStart = this.textBox1.TextLength;
}
}
先定义个全局变量 public int _n=1;
public int _nn=1;
if(e.KeyChar>=48 && e.KeyChar <=57)
{
e.Handled =false;
int i = this.textBox1.Text.Split('.').Length;
_n = i;
_nn=_n-1;
if(this.textBox1.TextLength % (3*_n + _nn)==0 )
{
this.textBox1.Text =this.textBox1.Text + ".";
this.textBox1.SelectionStart = this.textBox1.TextLength;
}
}