怎样可以让winform里的textbox, lable, combobox 之类的还原最初的值 怎样可以让winform里的textbox, lable, combobox 之类的还原最初的值 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 希望可以按一个button, 整个form回复到和最开始样子 我现在用的是一个很不好的方法public void controls_reset(params Control[] controls) { foreach (Control ctl in controls) { if (ctl.GetType().ToString() == "System.Windows.Forms.TextBox") { if(ctl.Visible != false) ctl.Text = "0"; } else if (ctl.GetType().ToString()=="System.Windows.Forms.ComboBox") { ComboBox ccb = (ComboBox)ctl; if (ccb.Items.Count > -1) { ccb.SelectedIndex = 0; } } else if (ctl.GetType().ToString() == "System.Windows.Forms.TextBox") { ctl.Text = ""; } else { MessageBox.Show("Unidentified control"); } } } 我见过一有人自己做的Form和控件,它追加了一个属性用来定义初始值.当要恢复初始值的时候只要一句话:Form.Reset(); 一般应该定义初始值,reset时重新赋值就可以了,比较简单。 简单!继承form控件,smartstar2005() 说的方法就可以实现了 可以用一个array 存下form的size 和location, new 一个新form同样的size 和location. 呵呵。Button bt=new Button();yourButton=bt.Text; datagridview 排序 帮忙看下这段程序,不让用对象,而直接用类 C#中用win32函数,求Win32API函数的所有常量值 子页面添加一个名称"中国"后对父页面的listbox控件中的项进行添加"中国" protected访问修饰符的应用求解惑!菜鸟小问! 小问题 mdi窗口,通过子窗口,调用另一个子窗口。怎么弄?谢谢。 关于动态行列装换 C#.netWinform中重新登入的实现机制 C#--WinForm调用COM实现语音功能 在线求助 (关于拖放, 背景色问题) 页面传值问题~!!!
{
foreach (Control ctl in controls)
{
if (ctl.GetType().ToString() == "System.Windows.Forms.TextBox")
{
if(ctl.Visible != false)
ctl.Text = "0";
}
else if (ctl.GetType().ToString()=="System.Windows.Forms.ComboBox")
{
ComboBox ccb = (ComboBox)ctl; if (ccb.Items.Count > -1)
{
ccb.SelectedIndex = 0;
}
}
else if (ctl.GetType().ToString() == "System.Windows.Forms.TextBox")
{
ctl.Text = "";
}
else
{
MessageBox.Show("Unidentified control");
}
}
}
yourButton=bt.Text;