📄 validate.cs
字号:
// Fig. 15.22: Validate.cs
// Validate user information using regular expressions.
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Text.RegularExpressions;
namespace Validate
{
/// <summary>
/// use regular expressions to validate strings
/// </summary>
public class validateForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Label phoneLabel;
private System.Windows.Forms.Label zipLabel;
private System.Windows.Forms.Label stateLabel;
private System.Windows.Forms.Label cityLabel;
private System.Windows.Forms.Label addressLabel;
private System.Windows.Forms.Label firstLabel;
private System.Windows.Forms.Label lastLabel;
private System.Windows.Forms.Button OkButton;
private System.Windows.Forms.TextBox phoneTextBox;
private System.Windows.Forms.TextBox zipTextBox;
private System.Windows.Forms.TextBox stateTextBox;
private System.Windows.Forms.TextBox cityTextBox;
private System.Windows.Forms.TextBox addressTextBox;
private System.Windows.Forms.TextBox firstTextBox;
private System.Windows.Forms.TextBox lastTextBox;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public validateForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.phoneLabel = new System.Windows.Forms.Label();
this.zipLabel = new System.Windows.Forms.Label();
this.stateLabel = new System.Windows.Forms.Label();
this.cityLabel = new System.Windows.Forms.Label();
this.addressLabel = new System.Windows.Forms.Label();
this.firstLabel = new System.Windows.Forms.Label();
this.lastLabel = new System.Windows.Forms.Label();
this.OkButton = new System.Windows.Forms.Button();
this.phoneTextBox = new System.Windows.Forms.TextBox();
this.zipTextBox = new System.Windows.Forms.TextBox();
this.stateTextBox = new System.Windows.Forms.TextBox();
this.cityTextBox = new System.Windows.Forms.TextBox();
this.addressTextBox = new System.Windows.Forms.TextBox();
this.firstTextBox = new System.Windows.Forms.TextBox();
this.lastTextBox = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// phoneLabel
//
this.phoneLabel.Location = new System.Drawing.Point(10, 240);
this.phoneLabel.Name = "phoneLabel";
this.phoneLabel.Size = new System.Drawing.Size(80, 24);
this.phoneLabel.TabIndex = 29;
this.phoneLabel.Text = "Phone";
this.phoneLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// zipLabel
//
this.zipLabel.Location = new System.Drawing.Point(10, 205);
this.zipLabel.Name = "zipLabel";
this.zipLabel.Size = new System.Drawing.Size(80, 24);
this.zipLabel.TabIndex = 28;
this.zipLabel.Text = "Zip";
this.zipLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// stateLabel
//
this.stateLabel.Location = new System.Drawing.Point(10, 170);
this.stateLabel.Name = "stateLabel";
this.stateLabel.Size = new System.Drawing.Size(80, 24);
this.stateLabel.TabIndex = 27;
this.stateLabel.Text = "State";
this.stateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// cityLabel
//
this.cityLabel.Location = new System.Drawing.Point(10, 135);
this.cityLabel.Name = "cityLabel";
this.cityLabel.Size = new System.Drawing.Size(80, 24);
this.cityLabel.TabIndex = 26;
this.cityLabel.Text = "City";
this.cityLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// addressLabel
//
this.addressLabel.Location = new System.Drawing.Point(10, 100);
this.addressLabel.Name = "addressLabel";
this.addressLabel.Size = new System.Drawing.Size(80, 24);
this.addressLabel.TabIndex = 25;
this.addressLabel.Text = "Address";
this.addressLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// firstLabel
//
this.firstLabel.Location = new System.Drawing.Point(10, 65);
this.firstLabel.Name = "firstLabel";
this.firstLabel.Size = new System.Drawing.Size(80, 24);
this.firstLabel.TabIndex = 24;
this.firstLabel.Text = "First Name";
this.firstLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// lastLabel
//
this.lastLabel.Location = new System.Drawing.Point(10, 30);
this.lastLabel.Name = "lastLabel";
this.lastLabel.Size = new System.Drawing.Size(80, 24);
this.lastLabel.TabIndex = 23;
this.lastLabel.Text = "LastName";
this.lastLabel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// OkButton
//
this.OkButton.Location = new System.Drawing.Point(112, 296);
this.OkButton.Name = "OkButton";
this.OkButton.TabIndex = 30;
this.OkButton.Text = "OK";
this.OkButton.Click += new System.EventHandler(this.OkButton_Click);
//
// phoneTextBox
//
this.phoneTextBox.Location = new System.Drawing.Point(100, 240);
this.phoneTextBox.Name = "phoneTextBox";
this.phoneTextBox.Size = new System.Drawing.Size(136, 20);
this.phoneTextBox.TabIndex = 22;
this.phoneTextBox.Text = "";
//
// zipTextBox
//
this.zipTextBox.Location = new System.Drawing.Point(100, 205);
this.zipTextBox.Name = "zipTextBox";
this.zipTextBox.Size = new System.Drawing.Size(136, 20);
this.zipTextBox.TabIndex = 21;
this.zipTextBox.Text = "";
//
// stateTextBox
//
this.stateTextBox.Location = new System.Drawing.Point(100, 170);
this.stateTextBox.Name = "stateTextBox";
this.stateTextBox.Size = new System.Drawing.Size(136, 20);
this.stateTextBox.TabIndex = 20;
this.stateTextBox.Text = "";
//
// cityTextBox
//
this.cityTextBox.Location = new System.Drawing.Point(100, 135);
this.cityTextBox.Name = "cityTextBox";
this.cityTextBox.Size = new System.Drawing.Size(136, 20);
this.cityTextBox.TabIndex = 19;
this.cityTextBox.Text = "";
//
// addressTextBox
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -