不用vs写form
来源:互联网 发布:mysql数据库方言 编辑:程序博客网 时间:2024/05/17 23:28
using System;
using System.Collections.Generic;
using System.Windows.Forms;
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.TextBox txtUserName;
private System.Windows.Forms.TextBox txtPassword;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.Button btnCancel;
private System.ComponentModel.Container components = null;
private int nLoginCount = 0;
private const int MAX_LOGIN_COUNT = 3;
private UserInfo uiLogin;
public Form1(UserInfo ui)
{
InitializeComponent();
uiLogin = ui;
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.txtUserName = new System.Windows.Forms.TextBox();
this.txtPassword = new System.Windows.Forms.TextBox();
this.btnOK = new System.Windows.Forms.Button();
this.btnCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
this.txtUserName.Location = new System.Drawing.Point(96, 48);
this.txtUserName.Name = "txtUserName";
this.txtUserName.TabIndex = 0;
this.txtUserName.Text = "";
this.txtPassword.Location = new System.Drawing.Point(96, 96);
this.txtPassword.Name = "txtPassword";
this.txtPassword.PasswordChar = '*';
this.txtPassword.TabIndex = 1;
this.txtPassword.Text = "";
this.btnOK.Location = new System.Drawing.Point(64, 152);
this.btnOK.Name = "btnOK";
this.btnOK.TabIndex = 2;
this.btnOK.Text = "button1";
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
this.btnCancel.Location = new System.Drawing.Point(152, 152);
this.btnCancel.Name = "btnCancel";
this.btnCancel.TabIndex = 3;
this.btnCancel.Text = "button1";
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.btnCancel);
this.Controls.Add(this.btnOK);
this.Controls.Add(this.txtPassword);
this.Controls.Add(this.txtUserName);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
[STAThread]
static void Main()
{
UserInfo ui = new UserInfo();
Application.Run(new Form1(ui));
}
private void btnOK_Click(object sender, System.EventArgs e)
{
if( txtUserName.Text == "Admin" && txtPassword.Text == "nopassword" )
{
// Save login user info
uiLogin.UserName = txtUserName.Text;
uiLogin.Password = txtPassword.Text;
// Set dialog result with OK
//this.DialogResult = DialogResult.OK;
MessageBox.Show("The username and password is right!");
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
this.Close();
}
}
public class UserInfo
{
private string strUserName;
private string strPassword;
public string UserName
{
get{ return strUserName;}
set{ strUserName = value; }
}
public string Password
{
get{ return strPassword;}
set{ strPassword = value;}
}
public UserInfo()
{
strUserName = "";
strPassword = "";
}
}
- 不用vs写form
- 不用操作系统写HelloWorld
- 不用xml写menu
- vs form设计器空白
- Form Data vs Request Payload
- 为什么不用C++写游戏
- windows编译xgboost-python,不用vs编译
- 写代码.VS.写作
- 写代码.VS.写作
- 写代码.VS.写作
- 写代码.VS.写作
- 写代码.VS.写作
- 写代码.VS.写作
- 写代码.VS.写作
- VS上写helloworld
- 写Form设计器尝试
- Form Data vs Request Payload(转)
- ASP不用FORM把input值传到下页
- 指令
- 说说装箱和拆箱
- .NET企业级应用架构设计系列之开场白
- 特权指令和非特权指令
- getpwnam() -- 获取用户属性
- 不用vs写form
- C#:冒泡排序
- 线性表顺序存贮
- VC实现XP风格控件效果
- jdbc事务处理 - 美丽人生 - JavaEye技术网站
- 面向对象分析和设计基本概念
- 标题 回调函数、消息和事件例程 xiaoran(原作)
- “少女的祈祷”已基本搞定
- CPU如何知道当前运行的是操作系统还是一般应用软件