C#从命令行运行窗体程序时隐藏窗体 [英] C# Hiding form when running form program from the command line

查看:140
本文介绍了C#从命令行运行窗体程序时隐藏窗体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个基于表单的程序,但是我已经被要求添加一些命令行支持,除了从表单闪烁和关闭,当从命令行运行时,它工作正常。是否还有在命令行运行时隐藏窗体?

I'm working on a program that is form based but I have been asked to add some command line support, this works fine apart from the form flashes up and closes down when running from the command line. Is there anyway to hide the form whilst the command line is running? Some code does refer to controls so the gui would need to be accessible but not visible, is this workable?

感谢

推荐答案

在您的Main方法中,您可以创建如下形式:

In your Main method you can create the form such as:

main = new MainForm();

然后进行任何需要的命令行处理。

then do any command line processing required.

当不在命令行模式时,只需调用:

When not in command line mode simply call:

Application.Run(main);

这篇关于C#从命令行运行窗体程序时隐藏窗体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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