📄 form1.cs
字号:
"14",
"15",
"16",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26",
"27",
"28",
"29",
"30",
"31"});
this.comboBox3.Location = new System.Drawing.Point(288, 72);
this.comboBox3.Name = "comboBox3";
this.comboBox3.Size = new System.Drawing.Size(48, 20);
this.comboBox3.TabIndex = 5;
//
// comboBox2
//
this.comboBox2.DropDownWidth = 64;
this.comboBox2.Items.AddRange(new object[] {
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12"});
this.comboBox2.Location = new System.Drawing.Point(216, 72);
this.comboBox2.Name = "comboBox2";
this.comboBox2.Size = new System.Drawing.Size(56, 20);
this.comboBox2.TabIndex = 4;
this.comboBox2.SelectedIndexChanged += new System.EventHandler(this.comboBox2_SelectedIndexChanged);
//
// comboBox1
//
this.comboBox1.DropDownWidth = 72;
this.comboBox1.Items.AddRange(new object[] {
"1950",
"1951",
"1952",
"1953",
"1954",
"1955",
"1956",
"1957",
"1958",
"1959",
"1960",
"1961",
"1962",
"1963",
"1964",
"1965",
"1966",
"1967",
"1968",
"1969",
"1970",
"1971",
"1972",
"1973",
"1974",
"1975",
"1976",
"1977",
"1978",
"1979",
"1980",
"1981",
"1982",
"1983",
"1984",
"1985",
"1986",
"1987",
"1988",
"1989",
"1990"});
this.comboBox1.Location = new System.Drawing.Point(128, 72);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(72, 20);
this.comboBox1.TabIndex = 3;
//
// button1
//
this.button1.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button1.Location = new System.Drawing.Point(144, 392);
this.button1.Name = "button1";
this.button1.TabIndex = 12;
this.button1.Text = "提交(&S)";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// listBox1
//
this.listBox1.ItemHeight = 12;
this.listBox1.Items.AddRange(new object[] {
"国家机关、政府部门",
"国有企业",
"三资企业",
"私营企业",
"学校、幼儿园",
"医院",
"公安、消防",
"军队、武警",
"法院、检察院",
"其它"});
this.listBox1.Location = new System.Drawing.Point(128, 136);
this.listBox1.Name = "listBox1";
this.listBox1.Size = new System.Drawing.Size(104, 88);
this.listBox1.TabIndex = 7;
//
// radioButton1
//
this.radioButton1.Checked = true;
this.radioButton1.Location = new System.Drawing.Point(128, 32);
this.radioButton1.Name = "radioButton1";
this.radioButton1.Size = new System.Drawing.Size(48, 24);
this.radioButton1.TabIndex = 1;
this.radioButton1.TabStop = true;
this.radioButton1.Text = "男";
//
// radioButton2
//
this.radioButton2.Location = new System.Drawing.Point(192, 32);
this.radioButton2.Name = "radioButton2";
this.radioButton2.Size = new System.Drawing.Size(48, 24);
this.radioButton2.TabIndex = 2;
this.radioButton2.Text = "女";
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(400, 421);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.comboBox3,
this.comboBox2,
this.label10,
this.label9,
this.label8,
this.comboBox1,
this.listBox1,
this.label7,
this.label6,
this.textBox2,
this.button1,
this.checkBox4,
this.checkBox3,
this.checkBox2,
this.checkBox1,
this.radioButton2,
this.radioButton1,
this.textBox1,
this.label5,
this.label4,
this.label3,
this.label2,
this.label1});
this.Name = "Form1";
this.Text = "用户注册";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void checkBox4_CheckedChanged(object sender, System.EventArgs e)
{
if(checkBox4.Checked == false)
{
if(MessageBox.Show("您真的不愿意接收我们的电子期刊吗?","提示",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation)==DialogResult.No)
checkBox4.Checked = true;
}
}
private void button1_Click(object sender, System.EventArgs e)
{
if(textBox1.Text == "")
{
MessageBox.Show("请输入姓名","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
textBox1.Focus();
return;
}
if(textBox2.Text == "")
{
MessageBox.Show("请输入Email地址","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
textBox2.Focus();
return;
}
if(textBox2.Text.IndexOf('@')==-1 || textBox2.Text.IndexOf('@')==0 || textBox2.Text.IndexOf('@')==textBox2.Text.Length-1)
{
MessageBox.Show("Email地址输入有误","提示",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
textBox2.Focus();
return;
}
MessageBox.Show("提交成功!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
this.Close();
}
private void comboBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
int month = comboBox2.SelectedIndex + 1;
comboBox3.Items.Clear();
//2月
if(month==2)
{
for(int i=1;i<=28;i++)
comboBox3.Items.Add(i);
return;
}
//小月
if(month==4 || month==6 || month==9 || month==11)
{
for(int i=1;i<=30;i++)
comboBox3.Items.Add(i);
return;
}
//大月
for(int i=1;i<=31;i++)
comboBox3.Items.Add(i);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -