JMA201-01
Fundamentals of Application Development

DEPARTMENT SCHEDULE SYLLABUS RESOURCES
Checkboxes and Radio Buttons

Checkboxes are interface elements that function independently of each other and allow a on/off style of choice. Radio buttons are elements that are used as a group, and allow the user to make an exclusive choice - the user can only select one at a time. Together, these elements can guide the user towards providing input in a controlled manner.

Any radio buttons on a common plane will interact with each other - meaning all radio buttons on the background form will be interactive and exclusive. To make multiple groups of radio buttons, use the GroupBox control (under Containers in the toolbox) and draw the radio buttons into this box.

The common prefix for checkboxes is chk, and for radio buttons is rdo. For either of these elements, the .checked property is used to see if the user has selected it. We usually have some sort of logic using if statements that takes does something if checked is true, and something else if checked is false, like in the following sample code:

Notice that in the case of the radio buttons, I had 3 buttons as a group. My logic is as follows: if they checked the first button (rdoCert) do something. If rdoCert.checked was false, it must be one of the other 2 buttons - check the next one (rdoGraduate). If rdoGraduate.checked was false as well, it must be the last radio button that was checked.

Note that with a group of radio buttons, once one has been selected, the user CANNOT deselect - they can only change the selected option. Therefore, it is always a good idea to provide the user some sort of Not Applicable/NA answer to prevent invalid data.

Sample Code