📄 form1.cs
字号:
namespace ch9_check
{
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.WinForms;
using System.Data;
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.WinForms.Form
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components;
private System.WinForms.TextBox textBox4;
private System.WinForms.Label label4;
private System.WinForms.CheckBox checkBox3;
private System.WinForms.Label label3;
private System.WinForms.TextBox textBox3;
private System.WinForms.Label label2;
private System.WinForms.TextBox textBox2;
private System.WinForms.CheckBox checkBox2;
private System.WinForms.Label label1;
private System.WinForms.TextBox textBox1;
private System.WinForms.CheckBox checkBox1;
public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
public override void Dispose()
{
base.Dispose();
components.Dispose();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container ();
this.label4 = new System.WinForms.Label ();
this.textBox4 = new System.WinForms.TextBox ();
this.label3 = new System.WinForms.Label ();
this.label2 = new System.WinForms.Label ();
this.label1 = new System.WinForms.Label ();
this.checkBox2 = new System.WinForms.CheckBox ();
this.checkBox3 = new System.WinForms.CheckBox ();
this.checkBox1 = new System.WinForms.CheckBox ();
this.textBox1 = new System.WinForms.TextBox ();
this.textBox3 = new System.WinForms.TextBox ();
this.textBox2 = new System.WinForms.TextBox ();
//@this.TrayHeight = 0;
//@this.TrayLargeIcon = false;
//@this.TrayAutoArrange = true;
label4.Location = new System.Drawing.Point (40, 168);
label4.Text = "Phone:";
label4.Size = new System.Drawing.Size (56, 16);
label4.TabIndex = 9;
textBox4.Location = new System.Drawing.Point (112, 168);
textBox4.Text = "textBox4";
textBox4.Enabled = false;
textBox4.TabIndex = 10;
textBox4.Size = new System.Drawing.Size (100, 20);
label3.Location = new System.Drawing.Point (40, 120);
label3.Text = "City";
label3.Size = new System.Drawing.Size (56, 16);
label3.TabIndex = 7;
label2.Location = new System.Drawing.Point (40, 96);
label2.Text = "Address:";
label2.Size = new System.Drawing.Size (56, 23);
label2.TabIndex = 5;
label1.Location = new System.Drawing.Point (40, 48);
label1.Text = "Name";
label1.Size = new System.Drawing.Size (64, 23);
label1.TabIndex = 2;
checkBox2.Location = new System.Drawing.Point (16, 72);
checkBox2.Text = "I know the address";
checkBox2.Size = new System.Drawing.Size (176, 24);
checkBox2.TabIndex = 3;
checkBox2.CheckedChanged += new System.EventHandler (this.checkBox2_CheckedChanged);
checkBox3.Location = new System.Drawing.Point (16, 144);
checkBox3.Text = "I know the phone number";
checkBox3.Size = new System.Drawing.Size (328, 24);
checkBox3.TabIndex = 8;
checkBox3.CheckedChanged += new System.EventHandler (this.checkBox3_CheckedChanged);
checkBox1.Location = new System.Drawing.Point (16, 16);
checkBox1.Text = "I know the name";
checkBox1.Size = new System.Drawing.Size (120, 24);
checkBox1.TabIndex = 0;
checkBox1.CheckedChanged += new System.EventHandler (this.checkBox1_CheckedChanged);
textBox1.Location = new System.Drawing.Point (112, 48);
textBox1.Text = "textBox1";
textBox1.Enabled = false;
textBox1.TabIndex = 1;
textBox1.Size = new System.Drawing.Size (232, 20);
textBox3.Location = new System.Drawing.Point (112, 120);
textBox3.Text = "textBox3";
textBox3.Enabled = false;
textBox3.TabIndex = 6;
textBox3.Size = new System.Drawing.Size (100, 20);
textBox2.Location = new System.Drawing.Point (112, 96);
textBox2.Text = "textBox2";
textBox2.Enabled = false;
textBox2.TabIndex = 4;
textBox2.Size = new System.Drawing.Size (232, 20);
this.Text = "Form1";
this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
this.ClientSize = new System.Drawing.Size (688, 421);
this.Controls.Add (this.textBox4);
this.Controls.Add (this.label4);
this.Controls.Add (this.checkBox3);
this.Controls.Add (this.label3);
this.Controls.Add (this.textBox3);
this.Controls.Add (this.label2);
this.Controls.Add (this.textBox2);
this.Controls.Add (this.checkBox2);
this.Controls.Add (this.label1);
this.Controls.Add (this.textBox1);
this.Controls.Add (this.checkBox1);
}
protected void checkBox3_CheckedChanged (object sender, System.EventArgs e)
{
EnableSet1();
EnableSet2();
EnableSet3();
}
protected void checkBox2_CheckedChanged (object sender, System.EventArgs e)
{
EnableSet1();
EnableSet2();
EnableSet3();
}
private void EnableSet1()
{
this.textBox1.Enabled = this.checkBox1.Checked;
}
private void EnableSet2()
{
this.textBox2.Enabled = this.checkBox2.Checked;
this.textBox3.Enabled = this.checkBox2.Checked;
}
private void EnableSet3()
{
this.textBox4.Enabled = this.checkBox3.Checked;
}
protected void checkBox1_CheckedChanged (object sender, System.EventArgs e)
{
EnableSet1();
EnableSet2();
EnableSet3();
}
/// <summary>
/// The main entry point for the application.
/// </summary>
public static void Main(string[] args)
{
Application.Run(new Form1());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -