重新加载窗体,无需关闭和重新打开

我有一个用c#编写的Windows窗体应用程序。 当有人按下“清除”按钮时,我想重新加载表单。 但我无法实现调用Load事件。这些行也不起作用:

this.Refresh(); this.Load +=new EventHandler(Grafik_Load); // 'Grafik' is the name of the form. 

我该怎么办? 谢谢你帮忙..

将’load’代码放在一个单独的函数中,并从您自己的代码/ Load事件处理程序中调用该函数。

  private void callonload() { //code which u wrriten on load event } private void Form_Load(object sender, EventArgs e) { callonload(); } private void btn_clear_Click(object sender, EventArgs e) { callonload(); } 

我发现hide / show,show部分创建了同一个表单的另一个实例,所以我最好处理当前的一个,创建它的新实例,并显示它。

 Grafik objFrmGrafik = new Grafik (); this.Dispose(); objFrmGrafik .Show(); 

Home是MDI-Form名称。 我测试过了。

  home.ActiveForm.Dispose(); home sd = new home(); sd.Show(); 
 //it is a good idea to use the 'sender' object when calling the form load method //because doing so will let you determine if the sender was a button click or something else... private void button2_Click(object sender, EventArgs e) { //you may want to reset any global variables or any other //housekeeping before calling the form load method Form1_Load(sender, e); } private void Form1_Load(object sender, EventArgs e) { if (sender is Button) { //the message box will only show if the sender is a button MessageBox.Show("You Clicked a button"); } }