c# - recognize which radio button is checked using enum as value, winforms -


i'm struggling winforms. inside winform have groupbox wrap 3 radio buttons. added them using design view , inside constructor tag every button corresponding enum value like

public myapp() {    radiobtnbasic.tag = userchoiceenum.basic;    radiobtnlite.tag = userchoiceenum.lite;    radiobtnstandard.tag = userchoiceenum.standard; } 

inside class have property property of type dictionary uses enum key, want when user click on winform button recognize radio button checked , assign dictionary.

i've found how fetch checked option

var choice = grpbox1.controls.oftype<radiobutton>().firstordefault(x => x.checked); 

do need use switch statement recognize enum checked or there better way?

if set tag can whenever need. note need cast original type. like:

var choiceasenum = (userchoiceenum)choice.tag; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -