如何在运行时动态隐藏当前表单并显示新表单 [英] How to dynamically hide current form during run time and show new form
问题描述
在下面我试图隐藏当前表单,并希望通过
Form5显示CrystalReport。它没有发生。正在发生的是两者都在展示。我可以通过Form5看到
Gridview'gvUserInfo'(我想隐藏)和CrystalReport。当然,
水晶报告是Gridview的幕后推手。如果我减去了Gridview,我可以看到Form5的结果。
我不想从我想要隐藏的当前表单中显示Gridview。
gvUserInfo.DataSource = ds11.Tables [0];
gvUserInfo.Visible = true;
this.Visible = false;
Form5 obj1 = new Form5();
obj1.Show();
In the following I am trying to hide the current form and want to show the CrystalReport through
Form5. It is not happening. What is happening is that both are showing. I could see the
Gridview 'gvUserInfo' (which I want to hide) and CrystalReport through Form5. Ofcourse the
crystal report is behind the Gridview. If I minus the Gridview, I could see the Form5 result.
I dont want the Gridview to be shown from the current form which I want to hide.
gvUserInfo.DataSource = ds11.Tables[0];
gvUserInfo.Visible = true;
this.Visible=false;
Form5 obj1 = new Form5();
obj1.Show();
推荐答案
在创建像这样的Form5对象之前,你可以很容易地使用this.Close()或this.Hide()方法。
this 。关(); //处理当前的表单对象。
Form5 obj1 = new Form5();
obj1.Show();
或
this.Hide(); //不要处理当前的表单对象。
Form5 obj1 = new Form5();
obj1.Show();
You can easily use this.Close() or this.Hide() method before creating Form5 object like this.
this.Close(); // Dispose the current form object.
Form5 obj1 = new Form5();
obj1.Show();
or
this.Hide(); // Do not dispose the current form object.
Form5 obj1 = new Form5();
obj1.Show();
这篇关于如何在运行时动态隐藏当前表单并显示新表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!