Visual Studio : The RadioButton

The RadioButton is a useful tool for distinct options which should not be selected together. Options that are selected together should be dealt with by using the CheckBox.

  • if Logic was applied to the visual properties of the CheckBox and to the RadioButton on a form, this would be a reasonable relationship:
    • CheckBox = AND – In a group, all to none of the CheckBoxes can be checked.
      • A group of options to work together, such as Manufacturer, Model, Description
      • A common function when searching the database for a component, is to have the Manufacturer, Model, and Description searchable together. As a companion, Notes for a component may contain a cross-reference to another component.
    • RadioButton = OR – In a group, only one RadioButton is checked.
      • A group of options which are not expected to work together, such as data ranges or values within a range.
      • As detailed below, there are radiobuttons House & Site, House, and Site. For example, the owner’s has a primary facility and the database has a unique SiteID (primary key). If the site ID is flagged as the “House“, by default all other addresses are Site. Selecting House & Site radiobutton would exclude the SQL Command WHERE clause, while the radiobuttons for House and Site would inlclude the WHERE SiteID = *HouseID” or WHERE SiteID <> *HouseID”. The three radiobuttons are OR options in the program.

Contrary to the visual behavior of the checkboxes and the radiobuttons, the programming utilizing the tools is totally programmer dependent whether in the AND or the OR applications.

Detail 1 – Designer vs. Running View Comparison

Detail 1 is a Designer view and a running of the Material Delivery Report. The focus here will be the operation of the RadioButton and how they function when grouped in a Panel. Note that a GroupBox is an option also and differs from a Panel as a GroupBox has a title and a visible outline when the program is running. Correspondently, the interior of both can be backcolored.

Note how the RadioButtons are grouped and labeled. The topmost Pane has the RadioButtons “All Projects” and “My Projects”. Below, the following panel has “House & Site”, “House”, and “Site” RadioButtons.

Normally, if a group of RadioButtons are placed in an area, only one RadioButton can be selected. If another RadioButton is selected, the previously selected RadioButton will become deselected.

Each of the Panels with RadioButtons have a different material review theme. On this program, Panels were chosen to separate the three themes: Project Selection, Delivery, and Time Span. To segregate the specific intent of the RadioButton groups, the groups were placed in Panels. The selection in one panel will not affect the selection in another panel. The Panels were back colored only to distinguish the group themes. Users will more readily distinguish the group functionality by the visual blocking just as well if titled Groupboxes were used.

As a programming note and probably a programmer’s preference, I change the handle of the on the RadioButton from its default RadioButton1.CheckedChanged to RadioButton1.Click.

The tool’s default handle is automatically loaded on the code form by double-clicking the tool on the design form.

Leave a Comment

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