为“显示”按钮编写“单击”(Click)事件处理代码,实现在TextBox中显示所填与所选信息(效果如下图所示)
答案:3 悬赏:70 手机版
解决时间 2021-02-07 05:05
- 提问者网友:原来太熟悉了会陌生
- 2021-02-06 13:36
最佳答案
- 五星知识达人网友:山君与见山
- 2021-02-06 14:59
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;
}
全部回答
- 1楼网友:有你哪都是故乡
- 2021-02-06 16:10
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;
}
- 2楼网友:北城痞子
- 2021-02-06 15:04
// 姓名
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;
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯