User Rating: 1 / 5

Star ActiveStar InactiveStar InactiveStar InactiveStar Inactive
 

RadioButton Control [System.Windows.Forms.RadioButton]

Enables the user to select a single option from a group of choices when paired with other radio buttons.

Default Event: CheckChanged

Why use a RadioButton control?

Use a radio button when you want to present users with a multiple choices, but only allow them to select one option. Radio buttons behave similar to a CheckBox Control, except that they work in conjunction with other radio buttons.

 

Grouping Radio Buttons:

By default radio buttons group with any other radio button located in the same container. Usually the container consists of the Form’s client area, but there are other controls you can use to group radio buttons:

Group Boxes:

Group Boxes

Panels:

Panels

Without using a container, the user will only be able to select a single option out of all the radio buttons, essentially creating one large group of options.

No Containers

 

Important Properties:

Checked

Indicates whether the radio button is checked or not.

Why use the Checked property?

Use the Checked property to determine the state of a specific radio button or when you want to check or uncheck a radio button.  When you set this property to True, the previously checked radio button in the group will be unchecked.

Values (Default: False):

True / False

Setting the Checked property in the script editor:

$radiobutton1.Checked =$true

 

Important Events:

CheckChanged

Occurs whenever the Checked property changes value.

Why use the CheckChanged event?

Use the CheckChanged property when you wish to respond to the user checking a radio button. This event also fires when the previously checked radio button is unchecked due to the user checking a different radio button.

The following is an example of the CheckChanged event. In this example, a label is set with the radio button’s text to inform the user when a radio button option is checked. We set the same CheckChanged event for all the radio buttons and use the $this variable to access the radio button that triggered the event. 

$radiobutton_CheckedChanged={
#Use the $this variable to access the calling control
#Only set the Label if this radio button is checked
	if($this.Checked -eq$true)
	{
		#Use the Radio Button's Text to set the label
		$labelSelected.Text =$this.Text    
	}
}

Now when the user checks a radio button, the name (Text property) of the radio button will be displayed.

Display Checked Radio Name

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Trial Software Questions forum.
Copyright © 2017 SAPIEN Technologies, Inc.