C#实现简单的Login窗口实例
更新时间:2015年08月24日 11:50:17 作者:我心依旧
这篇文章主要介绍了C#实现简单的Login窗口,实例分析了C#显示及关闭登陆Login窗口的技巧,非常具有实用价值,需要的朋友可以参考下
本文实例讲述了C#实现简单的Login窗口。分享给大家供大家参考。具体实现方法如下:
C# 制作登录窗体,登录成功之后正确的做法是关闭(close)登录窗体,而不是隐藏窗体(hide)
FrmLogin窗体:
public Form1()
{
InitializeComponent();
//登录按钮
button1.Click += delegate
{
this.DialogResult = DialogResult.OK;
this.Close();
};
//取消登录按钮
button2.Click += delegate
{
this.DialogResult = DialogResult.Cancel;
};
//窗体关闭
this.FormClosing += delegate(object sender, FormClosingEventArgs e)
{
if (this.DialogResult != DialogResult.Cancel && this.DialogResult != DialogResult.OK)
e.Cancel = true;
};
}
Main方法入口:
[STAThread]
tatic void Main(string[] args)
{
if (args.Length > 0)
MessageBox.Show(args[0]);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
FrmLogin f = new FrmLogin ();
if (f.ShowDialog() == DialogResult.OK)
{
Application.Run(new Form3());
}
}
希望本文所述对大家的C#程序设计有所帮助。
相关文章
在C#中使用适配器Adapter模式和扩展方法解决面向对象设计问题记录
在开发基于MonoGame的游戏框架时,面临SpriteFont和DynamicSpriteFont兼容问题,SpriteFont在内容管道中编译确定字号,导致不同字号需加载多个字体资源,本文给大家介绍在C#中使用适配器Adapter模式和扩展方法解决面向对象设计问题,感兴趣的朋友一起看看吧2024-10-10


最新评论