隐藏窗体。 [英] Hiding a windows form.

查看:63
本文介绍了隐藏窗体。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!!!

首次使用后可以隐藏Windows窗体吗?第一次使用后,这种形式不会出现。如果是,那怎么样?请有人帮我。我正在使用C#和SQL Server 2005开发基于Windows的应用程序。

Hi !!!
Is it possible to hide a windows form after first use of it ? That form shuold not be appeared after first use.If yes, then how? Please someone give me help. I am developing a Windows based Application by using C# and SQL Server 2005.

推荐答案

如果您调用表单 Hide()方法: http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharp [< a href =http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharptarget =_ blanktitle =新窗口> ^ ]
You can if you call the forms Hide() method : http://www.techotopia.com/index.php/Hiding_and_Showing_Forms_in_C_Sharp[^]


请请参阅我对解决方案1的评论。



因此,还有另一种技术可以让您逐个使用两种不同的主要形式。比方说,你有两个表格类;第一个是您想要在使用后永久隐藏的一次性表单,如果 IntroductionForm 则调用,另一个是您的永久主表单;称之为 MainForm



Please see my comment to Solution 1.

So, there is another technique which you could allow you to work with two different main form one by one. Let''s say, you have two form classes; first one is your single-use form you wanted to hide after use forever, call if IntroductionForm, and another one is your "permanent" main form; call it MainForm.

using System.Windows.Forms;

//...

        static void Main() {
            Application.Run(new IntruductionForm()); // during the use of this form, eventually close it instead of hiding
            // you won't need the instance of IntruductionForm, anyway, so it will be disposed; you won't be able to show it again,
            // but the resources it uses will be reclaimed, which is good
            Application.Run(new MainForm()); // since this point, everything goes in a usual way
        }

//...





当一个表单实例用作 Application.Run 的参数时,重要的是要理解它是一个主表单。与其他形式不同,当主窗体关闭时,方法 Application.Run 返回。



这解释了如何它有效。



-SA



It is important to understand that a form instance becomes a main form when it is used as an argument of Application.Run; unlike other forms, when a main form is closed, the method Application.Run returns.

This explains how it works.

—SA


这里有一个示例:

场景:如果值正确,有两个文本框,按钮打开一个新表格



here is a sample example for you:
scenario: having two textboxes with a button opening a new form if values are correct

Form2 f2 = new Form2();


       private void button1_Click(object sender, EventArgs e) // event of first forms button
       {

           if (textBox1.Text== "test" && textBox2.Text=="test")
           {

               f2.Show(); // will display new form
               this.Hide(); // hiding of current form
           }
           else
               MessageBox.Show("Entry not valid");
       }


这篇关于隐藏窗体。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆