为“显示”按钮编写“单击”(Click)事件处理代码,实现在TextBox中显示所填与所选信息(效果如下图所示)
展开全部
private void button1_Click(object sender, EventArgs e)
{
string a="";
string b="";
if (radioButton1.Checked)
{
a = "男";
}
else {
a = "女";
}
if (checkBox1.Checked) {
b = b + checkBox1.Text;
}
if (checkBox2.Checked)
{
b = b + checkBox2.Text;
}
if (checkBox3.Checked)
{
b = b + checkBox3.Text;
}
if (checkBox4.Checked)
{
b = b + checkBox4.Text;
}
textBox3.Text = "姓名" + textBox1.Text + "班级" + textBox2.Text + "性别" + a + "爱好" + b;
}
{
string a="";
string b="";
if (radioButton1.Checked)
{
a = "男";
}
else {
a = "女";
}
if (checkBox1.Checked) {
b = b + checkBox1.Text;
}
if (checkBox2.Checked)
{
b = b + checkBox2.Text;
}
if (checkBox3.Checked)
{
b = b + checkBox3.Text;
}
if (checkBox4.Checked)
{
b = b + checkBox4.Text;
}
textBox3.Text = "姓名" + textBox1.Text + "班级" + textBox2.Text + "性别" + a + "爱好" + b;
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
// 姓名
TextBox uname = new TextBox();
uname.Text = "zhangsan";
// 班级
TextBox uclass = new TextBox();
uclass.Text = "073361";
// 性别
RadioButton usex = new RadioButton();
usex.Text = "男";
RadioButton usext = new RadioButton();
usext.Text = "女";
// 爱好
CheckBox ulove = new CheckBox();
ulove.Text = "爱好1";
CheckBox ulove1 = new CheckBox();
ulove1.Text = "爱好2";
CheckBox ulove2 = new CheckBox();
ulove2.Text = "爱好3";
CheckBox ulove3 = new CheckBox();
ulove3.Text = "爱好4";
// 显示
Button Show = new Button();
Show.Text = "显示";
Show.Click += new EventHandler(ShowClick);
// 显示结果
TextBox ShowText = new TextBox();
// 你想要的方法
private void ShowClick(object sender, EventArgs e)
{
ShowText.Text =
"姓名为:" + uname.Text
+ " 班级为:" + uclass.Text
+ " 性别为:";
if (usex.CanSelect == true)
ShowText.Text += usext.Text;
else
ShowText.Text += ulove.Text;
ShowText.Text += " 爱好为:";
if (ulove.Checked == true) ShowText.Text += ulove.Text;
if (ulove1.Checked == true) ShowText.Text += ulove1.Text;
if (ulove2.Checked == true) ShowText.Text += ulove2.Text;
if (ulove3.Checked == true) ShowText.Text += ulove3.Text;
}
TextBox uname = new TextBox();
uname.Text = "zhangsan";
// 班级
TextBox uclass = new TextBox();
uclass.Text = "073361";
// 性别
RadioButton usex = new RadioButton();
usex.Text = "男";
RadioButton usext = new RadioButton();
usext.Text = "女";
// 爱好
CheckBox ulove = new CheckBox();
ulove.Text = "爱好1";
CheckBox ulove1 = new CheckBox();
ulove1.Text = "爱好2";
CheckBox ulove2 = new CheckBox();
ulove2.Text = "爱好3";
CheckBox ulove3 = new CheckBox();
ulove3.Text = "爱好4";
// 显示
Button Show = new Button();
Show.Text = "显示";
Show.Click += new EventHandler(ShowClick);
// 显示结果
TextBox ShowText = new TextBox();
// 你想要的方法
private void ShowClick(object sender, EventArgs e)
{
ShowText.Text =
"姓名为:" + uname.Text
+ " 班级为:" + uclass.Text
+ " 性别为:";
if (usex.CanSelect == true)
ShowText.Text += usext.Text;
else
ShowText.Text += ulove.Text;
ShowText.Text += " 爱好为:";
if (ulove.Checked == true) ShowText.Text += ulove.Text;
if (ulove1.Checked == true) ShowText.Text += ulove1.Text;
if (ulove2.Checked == true) ShowText.Text += ulove2.Text;
if (ulove3.Checked == true) ShowText.Text += ulove3.Text;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询