在启动时单个窗体隐藏 [英] Single Form Hide on Startup

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

问题描述

我有它一种形式的应用程序,并在Load方法我需要隐藏的形式。

I have an application with one form in it, and on the Load method I need to hide the form.

表单将显示自己时,它有必要(沿展望2003风格弹出的线条认为),但我不能想出如何隐藏加载的形式,而不凌乱的东西。

The form will display itself when it has a need to (think along the lines of a outlook 2003 style popup), but I can' figure out how to hide the form on load without something messy.

有什么建议?

推荐答案

我在这个即将从C#,但应该是在vb.net非常相似。

I'm coming at this from C#, but should be very similar in vb.net.

在您的主程序文件,在Main方法中,你会碰到这样的:

In your main program file, in the Main method, you will have something like:

Application.Run(new MainForm());

这将创建一个新的主要形式和应用程序的生命周期限制到主窗体的寿命。

This creates a new main form and limits the lifetime of the application to the lifetime of the main form.

但是,如果删除了参数Application.Run(),那么应用程序将与没有显示的形式开始,你就可以自由地显示和隐藏形式你喜欢。

However, if you remove the parameter to Application.Run(), then the application will be started with no form shown and you will be free to show and hide forms as much as you like.

而不是隐藏在形式Load方法,使用设计形式的Visible属性设为False。你可以调用Application.Run(),我假设的形式将有它的NotifyIcon显示在任务栏的图标之前创建的形式 - 这是可以即使窗体本身尚不可见显示

Rather than hiding the form in the Load method, set the Visible property of the form to False using the designer. You can create the form before calling Application.Run(), I'm assuming the form will have a NotifyIcon on it to display an icon in the task bar - this can be displayed even if the form itself is not yet visible.

更新:你也想给Application.ShutdownMode属性设置为ShutdownMode.OnExplicitShutdown

Update: You will also want to set the Application.ShutdownMode property to ShutdownMode.OnExplicitShutdown.

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

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