📄 login.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
namespace Login
{
/// <summary>
/// UserControl1 的摘要说明。
/// </summary>
///
public class Login : System.Windows.Forms.UserControl
{
public string LoginName
{
get
{
return NameTextBox.Text;
}
set
{
NameTextBox.Text=value;
}
}
public string PassWord
{
get
{
return PassTextBox.Text;
}
set
{
PassTextBox.Text=value;
}
}
private System.Windows.Forms.Label NameLabel;
private System.Windows.Forms.Label PassLabel;
private System.Windows.Forms.TextBox NameTextBox;
private System.Windows.Forms.TextBox PassTextBox;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public Login()
{
// 该调用是 Windows.Forms 窗体设计器所必需的。
InitializeComponent();
// TODO: 在 InitComponent 调用后添加任何初始化
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if( components != null )
components.Dispose();
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器
/// 修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.NameLabel = new System.Windows.Forms.Label();
this.PassLabel = new System.Windows.Forms.Label();
this.NameTextBox = new System.Windows.Forms.TextBox();
this.PassTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// NameLabel
//
this.NameLabel.AutoSize = true;
this.NameLabel.Location = new System.Drawing.Point(8, 16);
this.NameLabel.Name = "NameLabel";
this.NameLabel.Size = new System.Drawing.Size(54, 17);
this.NameLabel.TabIndex = 0;
this.NameLabel.Text = "登陆名:";
//
// PassLabel
//
this.PassLabel.AutoSize = true;
this.PassLabel.Location = new System.Drawing.Point(8, 64);
this.PassLabel.Name = "PassLabel";
this.PassLabel.Size = new System.Drawing.Size(42, 17);
this.PassLabel.TabIndex = 1;
this.PassLabel.Text = "密码:";
//
// NameTextBox
//
this.NameTextBox.Location = new System.Drawing.Point(88, 16);
this.NameTextBox.Name = "NameTextBox";
this.NameTextBox.Size = new System.Drawing.Size(120, 21);
this.NameTextBox.TabIndex = 2;
this.NameTextBox.Text = "";
this.NameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.NameTextBox_Validating);
//
// PassTextBox
//
this.PassTextBox.Location = new System.Drawing.Point(88, 64);
this.PassTextBox.Name = "PassTextBox";
this.PassTextBox.PasswordChar = '*';
this.PassTextBox.Size = new System.Drawing.Size(120, 21);
this.PassTextBox.TabIndex = 3;
this.PassTextBox.Text = "";
this.PassTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.PassTextBox_Validating);
//
// Login
//
this.Controls.Add(this.PassTextBox);
this.Controls.Add(this.NameTextBox);
this.Controls.Add(this.PassLabel);
this.Controls.Add(this.NameLabel);
this.Name = "Login";
this.Size = new System.Drawing.Size(216, 104);
this.ResumeLayout(false);
}
#endregion
private void NameTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if(NameTextBox.Text=="")
{
MessageBox.Show("登陆名不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
private void PassTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e)
{
if(PassTextBox.Text=="")
{
MessageBox.Show("密码不能为空!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -