简体   繁体   English

如何通过隐藏主表单从主表单打开表单

[英]How to open a form from main form by hiding the main form

I would like to ask what is the best way to implement functionality that: 我想问一下实现以下功能的最佳方法是什么:

User has for example 3 buttons on the main form, if he clicks on any button the form is replaced with another one where he has to fill some text controls and after clicking accept redirect him to the main form. 例如,用户在主表单上有3个按钮,如果他单击任意按钮,则该表单将替换为另一个表单,在该表单中,他必须填写一些文本控件,然后单击“接受”,将其重定向到主表单。

Is it done by using visible and switching it ? 通过使用可见并切换它来完成吗?

I hope there is much cleaner solution 我希望有更多更清洁的解决方案

thanks for help, bye 谢谢你的帮助,再见

It's essentially using the visible property of the form, but using the Form.Show() method to show the second form. 它本质上是使用窗体的visible属性,但是使用Form.Show()方法显示第二个窗体。

Form.Show() as far as I know is just a wrapper to changing the Visible property of the form. 据我所知,Form.Show()只是更改表单的Visible属性的包装器。

I'm going to assume VB.net on this one. 我将在此假设VB.net。

You'll need to create four different forms, Form1, Form2, Form3, Form4, etc. Form1 has the buttons on it, and each other Form (2,3,4) has the text fields on it with OK buttons which will close the forms. 您将需要创建四个不同的表单,Form1,Form2,Form3,Form4等。Form1上具有按钮,而彼此之间的Form(2,3,4)上都有带有确定按钮的文本字段,这些按钮将关闭表格。

So, for each button in Form1: 因此,对于Form1中的每个按钮:

dim tempForm as Form2 = new Form2
tempForm.showModal()  ' might be .showDialog()

And for each button in Form2,3,4 对于Form2、3、4中的每个按钮

me.hide  'might be this.hide

Sorry, I get my languages mixed up sometimes :P 抱歉,有时我的语言混杂起来:P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM