Team LiB
Previous Section Next Section

Representing Logical Values

Although you can display logical values in a text box, it's not a good practice. For example, a Customer table might contain a field called CreditApproved that you declared as a Boolean value. You could use a text box to display the field and then use data validation to check that users have entered "Yes," "No," "True," or "False." But allowing unlimited data entry like this is just begging for users to enter "Provisionally" or "Deadbeat." Unless you're prepared to accept and interpret these entries, you can do the users and yourself a favor by choosing a control that's limited to two values.

Both Access and Visual Studio provide two controls that do a better job: check boxes and toggle buttons, which are shown in Figure 18-2.

Figure 18-2. Each Check Box and Toggle Button Control Is Used to Display a Logical Value


Most people are familiar with check boxes, and they're a good choice for representing most logical values. Toggle buttons are used less frequently. They're more effective for Boolean values that equate to "on" and "off" rather than to "true" or "false." The problem with toggle buttons is that in their "off" state they're indistinguishable from command buttons. Since users expect that pressing a button will cause some action to be performed, many might be hesitant to press a button labeled "Credit Approved," thinking that doing so will initiate the approval process rather than simply indicate that it has been completed. For this reason, I prefer to use toggle buttons in sets, like radio buttons. This is, in fact, how they're implemented in Visual Studio. They are RadioButton controls with their Appearance property set to "Button".

On the subject of radio buttons (also known as option buttons), please don't use these controls to represent single logical values. Nothing in the Microsoft Windows environment actually prevents you from doing so, but it's unnecessary (check boxes do just as well) and inappropriate. Radio buttons are intended to represent a set of mutually exclusive choices. A single option button all by its lonesome looks peculiar.

Worse, if you're using option buttons to represent several logical values in the same area of the form, users are likely to erroneously believe that they are somehow related and that they can choose only a single option button at a time. They will also expect that selecting one option will automatically cause the others to be deselected. It's always disconcerting to users when a computer system doesn't behave as they expect.

    Team LiB
    Previous Section Next Section