码迷,mamicode.com
首页 > Windows程序 > 详细

窗体单例

时间:2016-02-02 20:38:08      阅读:184      评论:0      收藏:0      [点我收藏+]

标签:

using System.Windows.Forms;

namespace Keleyi.Com
{
public partial class AboutForm : Form
{
private static AboutForm _instance;

private AboutForm()
{
InitializeComponent();
}

private void AboutForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.CloseReason== CloseReason.UserClosing)
{
this.Hide();
e.Cancel = true;
}
}

public static AboutForm GetInstance()
{
if (_instance == null)
_instance = new AboutForm();

return _instance;
}
}
}
构造函数私有化,声明静态窗体变量

 

窗体单例

标签:

原文地址:http://www.cnblogs.com/wxlyq/p/5178435.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!