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; using System.Threading; namespace 表单 { public partial class Form1 : Form { public Form1() { InitializeComponent(); i1.Hide(); hobby.Hide(); i2.Hide(); i3.Hide(); button1.Location=new Point(102,105); } void an_man() { i1.Show(); i2.Show(); i3.Show(); hobby.Show(); i1.Checked = false; i2.Checked = false; i3.Checked = false; i1.Text = "玩游戏"; i2.Text = "打篮球"; i3.Text = "踢足球"; } void an_woman() { i1.Show(); i2.Show(); i3.Show(); hobby.Show(); i1.Checked = false; i2.Checked = false; i3.Checked = false; i1.Text = "看电视"; i2.Text = "聊天"; i3.Text = "打游戏"; } private void man_CheckedChanged(object sender, EventArgs e) { button1.Location = new Point(102, 193); an_man(); } private void woman_CheckedChanged_1(object sender, EventArgs e) { an_woman(); button1.Location = new Point(102, 193); } private void button1_Click(object sender, EventArgs e) { textBox1.Text = textBox1.Text.Trim(); if (textBox1.Text != ""&&man.Checked||woman.Checked) { label1.Hide(); } if (textBox1.Text == "") { label1.Text = "请填写你的姓名"; } else if (!man.Checked && !woman.Checked) { label1.Text = "请填写你的姓别"; } else { string xb,i=""; if (i1.Checked) { i += i1.Text+" "; } if (i2.Checked) { i += i2.Text+" "; } if (i3.Checked) { i += i3.Text; } if (man.Checked) { xb = "男"; } else { xb = "女"; } MessageBox.Show("姓名:"+textBox1.Text+"\n性别:"+xb+"\n爱好:"+i); } } } }
标签:Checked,c#,Text,i3,i2,System,表单,i1 From: https://www.cnblogs.com/wangyueshuo/p/18290047