更改启动页面

Changing the startup page

我正在创建一个应用程序来存储用户所做的设置选择。其中一些选择旨在控制在程序启动时打开应用程序中的哪个表单。

我一直在寻找实现此目的的方法,但尚未找到可行的方法。我找到了许多更改 "permanent" 启动表单的方法,但没有找到更改应用程序内默认表单的方法。 我什至愿意通过使用命令行参数启动来控制它,例如...

tce.exe /profile 与 tce.exe /custom

感谢您提供有关如何完成此任务的想法。

您可以在名为 Main 的静态无效方法中的 Program.cs class 中进行调整。示例:

static class Program
{
    static void Main()
    {
        // custom logic here to determine which form to show
        if (Settings.Default.IsAdmin)
        {
            Application.Run(new Form1());
        }
        else
        {
            Application.Run(new Form2());
        }
    }
}

确保 启动对象 设置为项目属性中的 Program class。