Getting values from radio button groups

Apr 16, 2014 at 8:47 AM
Hello together,

first of all ... this project is really cool.

Actually I try to build my first GUI application in Powershell. Right now I have the challange, to use the checked value from a radio button group. Can someone give me a hint how to get these values inside a variable ? My example code is :

New-RadioButton -name rad -Content 'German' -GroupName Language
New-RadioButton -name rae -Content 'English' -GroupName Language

How can I assign the language which was checked to a variable.

By the way, is there a documentation online, where I can get the attributes and properties of the showui commandlets ?

Thanks a lot in front for your help.

Apr 16, 2014 at 6:30 PM
As a general rule, the documentation for commands like New-RadioButton is the documentation for the RadioButton itself on MSDN ... I've been meaning to have that show as the -Online help link...

The code to output the value is the same as for anything else in ShowUI, which is basically to call Set-UIValue at some point.

In this case, I'd just call Set-UIValue when it's closing:
window -SizeToContent WidthAndHeight { 
   stackpanel {
      radiobutton -name rad -Content German -GroupName Language
      radiobutton -name rae -Content English -GroupName Language
} -On_Closing { Set-UIValue $Window } -Show
If you wanted to just return the NAME of the selected radiobutton, then use Get-UIValue and calculate what you want then then use Set-UIValue $Window $YourValue
-On_Closing { 
  $values = Get-UIValue $Window
  $Selected = $values.GetEnumerator() | Where { $_.Value }
  Set-UIValue $Window $Selected.Name