在C#选择不同的radioButton,然后在lable1中显示不同的答案,在button中应该输入什么代码?

 我来答
zhuxinjun1982
2012-12-21 · 知道合伙人互联网行家
zhuxinjun1982
知道合伙人互联网行家
采纳数:2145 获赞数:8328
毕业于上海行健职业学院,大专学历;2007~2009在北大青鸟进修网络编程课目。现任网络主管,平时爱好上网。

向TA提问 私信TA
展开全部
要完成你的需求,目前只有这样写,已经测试过,没问题。还有这里应该用ELSE IF,不该用IF。应该是radioButton1.Text;而不是直接赋值。

private void button1_Click(object sender, EventArgs e)
{
for (int i = 1; i <= 4; i++)
{
if (radioButton1.Checked == true)
{
this.label1.Text = radioButton1.Text;
}
else if (radioButton2.Checked == true)
{
this.label1.Text = radioButton2.Text;
}
else if (radioButton3.Checked == true)
{
this.label1.Text = radioButton3.Text;
}
else if (radioButton4.Checked == true)
{
this.label1.Text = radioButton4.Text;
}
}
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
zc_hades
2012-12-21 · TA获得超过181个赞
知道小有建树答主
回答量:262
采纳率:0%
帮助的人:110万
展开全部
触发radioButton点击事件的时候,如果radioButton1被选中 label1.Text = "asd"

.......radioButton2被选中 label1.Text ="xzcxcz"

....... radioButton3被选中label1.Text = "vvbnbn";
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
公贺拨茗Uk
2012-12-21
知道答主
回答量:15
采纳率:0%
帮助的人:7.6万
展开全部
if(this.控件ID.SelectedValue=="1")
{
lable.text="你要的值"
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
donny945
2012-12-21 · TA获得超过310个赞
知道小有建树答主
回答量:378
采纳率:0%
帮助的人:312万
展开全部
private void button1_Click(object sender, EventArgs e)
{
if (radioButton1.Checked)
{
this.label1.Text = "radioButton1";
}
if (radioButton2.Checked)
{
this.label1.Text = "radioButton2";
}
if (radioButton3.Checked)
{
this.label1.Text = "radioButton3";
}
if (radioButton4.Checked)
{
this.label1.Text = "radioButton4";
}
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(2)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式