首页 > 解决方案 > 有没有办法不显示 windows 窗体?

问题描述

有没有办法,比如说,抑制 InitializeComponent?我目前正在尝试制作一种选择你自己的冒险的东西,我想知道是否有可能阻止表单打开,因为我使用的是消息框而不是数千个表单。

标签: c#winforms

解决方案


似乎您根本不​​想要一个表单,而是试图用消息框做所有事情。除了设计之外,您不需要表单来显示MessageBox. 您所需要的只是对System.Windows.Forms.

例如:

using System;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    static class Program
    {   
        [STAThread]
        static void Main()
        {
            // gut everything else from the Windows Forms Application template
            MessageBox.Show("Hello World");
        }
    }
}

推荐阅读