【发布时间】:2012-02-14 19:40:19
【问题描述】:
我有一个枚举
public enum Operation
{
Add = 1,
Substract = 2,
Multiply = 3,
Divide = 4
}
我有四个单选按钮:加、减、乘、除。
根据选择,我想返回对应的 Enum 值。我所有的单选按钮都出现在一个组合框中。
我知道这是一件简单的事情,但很长一段时间我都无法做到。谢谢。
编辑
这就是我尝试过的......
public Operation Operation
{
get
{
foreach (Control control in gbxOperation.Controls)
{
var radioButton = control as radioButton;
if (radioButton != null && radioButton.Checked)
{
if(radioButton.Text.ToLower() == "add")
return Operation.Add;
if (radioButton.Text.ToLower() == "subtract")
return Operation.Substract;
if (radioButton.Text.ToLower() == "multiply")
return Operation.Multiply;
if (radioButton.Text.ToLower() == "divide")
return Operation.Divide;
}
}
return Operation.Add;
}
}
【问题讨论】:
-
Winforms?网络表格? WPF? MVC? WP7?银光?地铁?单触? MonoDroid?
-
请显示单选按钮事件的代码。
-
你在 UI 上使用什么 asp.net、winforms、WPF?
-
地铁?表格? WPF?银光? ASP.NET?单触?
-
这是作业吗?你试过什么?