编写一个学生注册界面
要用到的控件
lable、textbox、groupbox、radioButton、checkBox、comboBox、button。
代码如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace _20190701048周皇实验二
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string a = "";
a += textBox1.Text + ",您好,欢迎进入C#世界!\n";
a += "您的密码是:" + textBox2.Text;
if (radioButton1.Checked)
a += "\n您的性别是:" + radioButton1.Text;
if (radioButton2.Checked)
a += "\n您的性别是:" + radioButton2.Text;
a += "\n您的学校是:" + comboBox1.Text;
a += "\n您的专业是:" + comboBox2.Text;
a += "\n您的爱好是:";
if (checkBox1.Checked)
a += checkBox1.Text + " ";
if (checkBox2.Checked)
a += checkBox2.Text + " ";
if (checkBox3.Checked)
a += checkBox3.Text + " ";
if (checkBox4.Checked)
a += checkBox4.Text + " ";
a += "\n人生状态是:";
if (radioButton3.Checked)
a += radioButton3.Text;
if (radioButton4.Checked)
a += radioButton4.Text;
if ((!radioButton1.Checked) && (!radioButton2.Checked))
MessageBox.Show("你是人妖么?(填写性别!!!)");
if ((!radioButton3.Checked) && (!radioButton4.Checked))
MessageBox.Show("你是挂了吗?(怎么能没有人生状态!!!)");
if ((!checkBox1.Checked) && (!checkBox2.Checked) && (!checkBox3.Checked) && (!checkBox4.Checked))
MessageBox.Show("这个做人嘛!还是要有点兴趣爱好的!!!");
if (textBox1.Text == "")
MessageBox.Show("请填写姓名!!!");
if (textBox2.Text == "")
MessageBox.Show("请输入密码!!!");
if (comboBox1.Text == "")
MessageBox.Show("请选择你所在的学校!!!");
if (comboBox2.Text == "")
MessageBox.Show("请选择你的专业!!!");
label9.Text = a;
}
}
}
运行结果: