1
我有枚舉數據類型顯示枚舉的WinForms
public enum UserChoices { Basic = 0, Lite = 1, Standard = 2 };
如何使用內部的WinForms單選按鈕選擇該枚舉財產?
我有枚舉數據類型顯示枚舉的WinForms
public enum UserChoices { Basic = 0, Lite = 1, Standard = 2 };
如何使用內部的WinForms單選按鈕選擇該枚舉財產?
使用下面的代碼來獲取數組中的名稱和值。
string[] names = Enum.GetNames(typeof(MyEnum));
MyEnum[] values = (MyEnum[])Enum.GetValues(typeof(MyEnum));
現在
for(int i = 0; i < names.Length; i++)
{
//Add this item to radio button list
//names[i] will be going to text
//values[i] will be going to value
}
查詢歡迎!
Duplicated - http://stackoverflow.com/a/9283542/1426106此外,谷歌上有很多例子。 – ilansch
參考此:http://stackoverflow.com/questions/2476829/winforms-bind-enum-to-radio-buttons – Koushik