C#实现简单的Login窗口实例
作者:我心依旧 时间:2021-07-18 02:23:29
本文实例讲述了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#,Login,窗口
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
关于activemq安装配置以及启动错误的解决
2023-11-13 05:18:02
![](https://img.aspxhome.com/file/2023/5/59485_0s.png)
java 生成xml并转为字符串的方法
2023-01-07 08:27:30
Struts2中validate数据校验的两种方法详解附Struts2常用校验器
2022-06-03 11:08:13
![](https://img.aspxhome.com/file/2023/4/96604_0s.png)
Java Socket编程实例(四)- NIO TCP实践
2021-10-07 13:44:35
Android ViewPager实现图片轮翻效果
2023-08-01 00:30:57
spring中向一个单例bean中注入非单例bean的方法详解
2022-07-19 13:14:18
![](https://img.aspxhome.com/file/2023/7/62167_0s.png)
Java两种方式实现动态代理
2022-10-15 22:12:23
Java微信公众平台开发(15) 微信JSSDK的使用
2023-06-16 19:58:39
![](https://img.aspxhome.com/file/2023/8/78048_0s.jpg)
Spring Boot 开发环境热部署详细教程
2023-07-28 01:50:02
浅谈JDK8中的Duration Period和ChronoUnit
2023-01-07 20:10:01
![](https://img.aspxhome.com/file/2023/9/97959_0s.jpg)
Android Studio使用小技巧:提取方法代码片段
2023-11-14 19:35:20
![](https://img.aspxhome.com/file/2023/9/87299_0s.gif)
java实现微信公众号发送模版消息
2022-04-23 08:09:11
C#中深拷贝和浅拷贝的介绍与用法
2022-11-04 07:42:46
![](https://img.aspxhome.com/file/2023/8/98198_0s.jpg)
SpringBoot结合Redis配置工具类实现动态切换库
2022-04-15 14:14:13
Android实现双击返回键退出应用实现方法详解
2023-03-23 21:33:29
![](https://img.aspxhome.com/file/2023/0/87320_0s.gif)
java实现鲜花销售系统
2023-08-29 20:23:42
![](https://img.aspxhome.com/file/2023/3/58333_0s.jpg)
python调用java的Webservice示例
2021-07-31 13:36:09
springboot 在idea中实现热部署的方法
2022-10-24 22:27:19
![](https://img.aspxhome.com/file/2023/8/70518_0s.png)
C++中求余运算符(%)示例详解
2023-11-02 14:20:39
C#动态加载dll扩展系统功能的方法
2022-08-08 23:23:15