C# 如何调用启动窗体

Program.cs中代码如下:

using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace test1
{
    public static class Program
    {
        public static Main main;
        public static Main GetMain()
        {
            if (main == null || main.IsDisposed)
            {
                main = new Main();
            }
            return main;
        }
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [MTAThread]
        public static void Main()
        {
            Application.Run(GetMain());
        }
    }
}

 

调用如下:

private void button3_Click(object sender, EventArgs e)
        {
            Program.GetMain().Show();
        }

 

posted @ 2016-06-30 16:41  npucloud  阅读(1244)  评论(0编辑  收藏  举报