求高手指点 如图有3个选项我选择一个点确定就会弹出提示 弹出的内容就是我选项上的内容 现在我就是不知道怎么弹出提示if... else里就是不知道该怎么写 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 if (radioButton1.Checked) { MessageBox.Show(radioButton1.Text.ToString()); } private void button1_Click(object sender, EventArgs e) { foreach (Control control in groupBox1.Controls) { if (((RadioButton)control).Checked) { MessageBox.Show(((RadioButton)control).Text); } } } 用control就可以实现了,不用繁琐的使用if...else语句。如果gropbox1中有其它控件,那就需要加上try...catch捕获异常private void button1_Click(object sender, EventArgs e) { foreach (Control control in groupBox1.Controls) { try { if (((RadioButton)control).Checked) { MessageBox.Show(((RadioButton)control).Text); } } catch (Exception) { continue; } } } 如果(单选按钮 == 被选中了){ 弹出你选择的内容}if(radioButton.Checked == true){ MessageBox.Show(radioButton.Text);} private void button1_Click(object sender, EventArgs e) { foreach (Control control in groupBox1.Controls) { if (((RadioButton)control).Checked) { MessageBox.Show(((RadioButton)control).Text); } } } if (radioButton1.Checked) { MessageBox.Show(radioButton1.Text.ToString()); } var radioText = Controls.Cast<RadioButton>().First(rdo => rdo.Checked).Text;MessageBox.Show(radioText); System.OutOfMemoryException的异常是怎么回事? 怎么获取控制台程序返回值 急求需要能运行出来的完整程序!急啊! SqlCommand .Parameters 竟然有防止sql注入攻击的功能吗? C#中的datagridview的刷新问题 TabConrol控件的选项卡问题 C#录音机程序 求解:C#服务器端解压ZIP文件 請教:運行時指定事件句柄無效的解決方法 打印DataGrid内容时,是用水晶报表打印,还是用其它方法呢? 纯技术贴!思胜第一季:C# 基础 0 - 前言 C# switch()语句分支过多时,有没有别的方式实现呢?
{
MessageBox.Show(radioButton1.Text.ToString());
}
private void button1_Click(object sender, EventArgs e)
{
foreach (Control control in groupBox1.Controls)
{
if (((RadioButton)control).Checked)
{
MessageBox.Show(((RadioButton)control).Text);
}
}
}
如果gropbox1中有其它控件,那就需要加上try...catch捕获异常private void button1_Click(object sender, EventArgs e)
{
foreach (Control control in groupBox1.Controls)
{
try
{
if (((RadioButton)control).Checked)
{
MessageBox.Show(((RadioButton)control).Text);
}
}
catch (Exception)
{ continue;
}
}
}
如果(单选按钮 == 被选中了)
{
弹出你选择的内容
}if(radioButton.Checked == true)
{
MessageBox.Show(radioButton.Text);
}
{
foreach (Control control in groupBox1.Controls)
{
if (((RadioButton)control).Checked)
{
MessageBox.Show(((RadioButton)control).Text);
}
}
}
{
MessageBox.Show(radioButton1.Text.ToString());
}
var radioText = Controls.Cast<RadioButton>().First(rdo => rdo.Checked).Text;
MessageBox.Show(radioText);