Powershell and Forms (part 4) – Radio buttons and Grouping

Radio buttons and Grouping

Radio buttons are another element used when creating forms. They allow a user to select one option from a group. For example, you post a question on a form – “Do you like cheese?” – The options for the answer would be “Yes – I like cheese”, “No – I don’t like cheese” or “Sometimes – depending on the type of cheese”. These answers cover all the possible answers to the question. When presented to the end user you only want them to select one option from the group.

To set this up in Powershell we have to do a few things, create a group for the radio buttons, create the radio buttons and give them values, create the form and add the usual “OK” and “Cancel” buttons. The code for all of this is below.

 

In the script above I have including a little piece that deals pop-up windows. Have fun with the script and as always, feel free to comment.

11 comments

  1. Great info. Lucky me I just found your web site by mistake (stumbleupon).
    We have book-marked it for later!

  2. Good post. I learn something new and challenging on blogs I stumbleupon every day.
    It will always be useful to read content from other
    authors and use a little something from other sites.

  3. Hmm it seems like your blog ate my first comment (it was super
    long) so I guess I’ll just sum it up what I wrote and say, I’m thoroughly enjoying your blog.
    I as well am an aspiring blog writer but I’m still new to the whole thing.
    Do you have any tips and hints for newbie blog writers? I’d certainly appreciate it.

    1. Hi, If you want to start a blog then the first thing to do is find a topic you really like and something you can talk about all day long. The next part is to write, then write more and then keep writing. The process and followers may be slow (depending on your topic of choice) but keep at it. And when you feel you are getting nothing for your work you need to keep at it. Make the time, write your posts and answer all your comments promptly. Best of luck.

  4. Nice post. I will link user4ws here when they have issues with using forms.
    You might be interested in:
    http://www.sapien.com/blog/topics/user-interface-design-for-administrators/
    http://www.sapien.com/blog/topics/spotlight-on-controls/

    Some additions.
    #1 You do not need to load System.Windows.Drawing for this form.
    #2 It is easier to set the DialogResult as a string:
    $CancelButton.DialogResult=’Cancel’
    #3 It is not necessary to set both the Form and button for the Accept/Cancel options. I find it more convenient to do on the button when it is created. The way you do this affects validation.

Leave a Reply

Your email address will not be published. Required fields are marked *