为“显示”按钮编写“单击”(Click)事件处理代码,实现在TextBox中显示所填与所选信息(效果如下图所示)
发布网友
发布时间:2022-05-01 18:31
我来回答
共3个回答
热心网友
时间:2023-10-23 21:05
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;
}
热心网友
时间:2023-10-23 21:05
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;
}
热心网友
时间:2023-10-23 21:05
// 姓名
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;
}
热心网友
时间:2023-10-23 21:05
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;
}
热心网友
时间:2023-10-23 21:05
// 姓名
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;
}
热心网友
时间:2023-10-23 21:06
你保证是弄错了
热心网友
时间:2023-10-23 21:05
// 姓名
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;
}
热心网友
时间:2023-10-23 21:06
你保证是弄错了
热心网友
时间:2023-10-23 21:06
你保证是弄错了