注册
来源:互联网 发布:裸机u盘装Ubuntu 编辑:程序博客网 时间:2024/04/28 12:49
using System;
using System.Windows.Forms;
namespace Test_01_注册_
{
public partial class My_Frm01 : Form
{
public My_Frm01()
{
InitializeComponent();
}
private void btnOk_Click(object sender, EventArgs e)
{
try
{
string strId = this.txtId.Text;
string strPwd = this.txtPwd.Text;
decimal decAge = this.NumAge.Value;
string strBirth = this.dtpBirth.Text;
string strPhone = this.mtbPhone.Text;
string strRemark = this.richTextBox1.Text;
string strSex = "";
foreach (RadioButton Sex in this.groupBoxSex.Controls) //获取性别
{
if (Sex.Checked)
{
strSex = Sex.Text;
break;
}
}
string strHobby = "";
foreach (CheckBox H in this.grbHobby.Controls) //获取爱好
{
if (H.Checked)
{
strHobby += H.Text;
}
}
string strInf = "";
foreach (var s in this.ckbInformation.CheckedItems) //信息来源
{
strInf += s.ToString() + " ";
}
MessageBox.Show(string.Format("用户名为:{0},密码为:{1},性别为:{2},年龄为:{3},出生日期为:{4},联系电话为:{5},所在省市为{6}{7},爱好为{8},信息来源为:{9},备注为:{10}", strId, strPwd, strSex, decAge, strBirth, strPhone, this.cobProvience.Text, this.cobCity.Text, strHobby, strInf, strRemark));
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void cobProvience_SelectedIndexChanged(object sender, EventArgs e)
{
this.cobCity.Items.Clear();
switch (this.cobProvience.Text) //省市
{
case "河南省":
this.cobCity.Items.Add("郑州市");
this.cobCity.Items.Add("鹤壁市");
this.cobCity.Items.Add("漯河市");
this.cobCity.Items.Add("信阳县");
break;
case "湖北省":
this.cobCity.Items.Add("武汉市");
this.cobCity.Items.Add("孝感市");
this.cobCity.Items.Add("天门市");
this.cobCity.Items.Add("来凤县");
break;
case "湖南省":
this.cobCity.Items.Add("常德");
this.cobCity.Items.Add("不知道");
this.cobCity.Items.Add("失败啊");
this.cobCity.Items.Add("还是不知道");
break;
default:
break;
}
}
}
}