110,501
社区成员
发帖
与我相关
我的任务
分享
foreach (object mycons in this.Controls)
{
if (mycons.GetType().ToString() == "System.Windows.Forms.TextBox")
{
TextBox mybox = (TextBox)mycons;
mybox.Text = "";
}
}
public class MyTextbox : TextBox
{
private Regex regExp = new Regex("");
public string RuleRegex
{
get { return regExp.ToString(); }
set
{
try
{
regExp = new Regex(value);//尝试匹配
}
catch
{
regExp = new Regex("");
}
}
}
protected override void OnLeave(EventArgs e)
{
base.OnLeave(e);
if (!regExp.IsMatch(this.Text)) this.Text = string.Empty;
}
}
foreach (object mycons in this.form1.Controls)
{
if (mycons.GetType().ToString() == "System.From.TextBox")//好象是这样,忘了...
{
TextBox mybox= (TextBox)mycons;
mybox.Text = "";
}
}