在WinForm中,保存完毕以后,如何让所有的TextBox的Text恢复默认值? 保存数据完成以后,如何恢复,重置 TextBox 的Text默认值(比如清空)好象没有重置Form的属性和方法,有什么办法? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 循环判断是不是TextBox控件,是就清空 WinForm怎么这么麻烦?只有这么一个办法吗?大家都是这么弄的吗?相比WebForm方便多了 window.location.href=window.location.href; 你可以调用 InitializeComponent();这是初始化窗体的。之前要删了所有的先this.SuppendLayOut();foreach(Control obj in this.Controls){ this.Controls.Remove(obj);}InitializeComponent();this.ResumeLayOut(); 移除写错了。这样this.Controls.Clear(); this.SuspendLayout();this.Controls.Clear();this.InitializeComponent();this.ResumeLayout(); wuyazhe(我的宝贝叫阿刺) 的解決方法會將所有控件的Text刪除的﹐包括Label等﹐如下代碼應該能實現的要求﹕foreach(Control ctl in this.Controls ){ if (ctl.GetType() == typeof(System.Windows.Forms.TextBox)) ctl.Text = "";} window.location.href=window.location.hrefWeb中是重定向到本页,是所有的都恢复了默认值了吧,那应该算是投机取巧的方法。WinForm你重新调InitializeComponent()试试 foreach(Control ctl in this.Controls ){ if (ctl.GetType() == typeof(System.Windows.Forms.TextBox)) { if(((TextBox)ctl).CanUndo == true) { ((TextBox)ctl).Undo(); ((TextBox)ctl).ClearUndo(); } }} foreach (Control con in this.Controls){ if (con is TextBox) con.Text = "";} 多谢各位大侠指教,看来只好用一匹狼的方法了。我要在基类里,把他封装成 FormReload()的一个方法。以后省得麻烦。 各位大侠 急求帮助啊 数据库问题 请教读取页面时的出错处理 保存图片时出错GDI+一般性 求助:正则表达式匹配 怎样把中文转为unicode 我是新手,请各位帮忙 winform 文本框输入的值保存到本地XML里。我在项目有XML文件 关于QueryString 请问怎么样从服务器硬盘上(非Web目录)下读取一个文件(如Word、zip等格式文件)并发送给客户端,客户端可正常浏览或下载? 如何解决XmlSerializer序列化过程中换行丢失? 我想一定有人遇到过. :) window程序--如何实现文件相对路径???
这是初始化窗体的。
之前要删了所有的先this.SuppendLayOut();
foreach(Control obj in this.Controls)
{
this.Controls.Remove(obj);
}
InitializeComponent();
this.ResumeLayOut();
this.Controls.Clear();
this.Controls.Clear();
this.InitializeComponent();
this.ResumeLayout();
foreach(Control ctl in this.Controls )
{
if (ctl.GetType() == typeof(System.Windows.Forms.TextBox))
ctl.Text = "";
}
{
if (ctl.GetType() == typeof(System.Windows.Forms.TextBox))
{
if(((TextBox)ctl).CanUndo == true)
{
((TextBox)ctl).Undo();
((TextBox)ctl).ClearUndo();
}
}
}
{
if (con is TextBox)
con.Text = "";
}
我要在基类里,把他封装成 FormReload()的一个方法。以后省得麻烦。