How to Enable One Check Box While Disabling the Others

ID: Q111918

2.50 2.50a 2.50b | 2.00 2.50 2.50a 2.50b | 2.50b

WINDOWS          | MS-DOS                | MACINTOSH
kbprg

The information in this article applies to:

SUMMARY

It is often desirable to enable one check box while disabling the others on a screen. By enabling only one check box and disabling the others, the color of the disabled ones will change and become dimmed. This will emphasize that only one of these check boxes can be selected at any given time.

See the procedure below for a demonstration of how to accomplish this.

MORE INFORMATION

Below are the steps to create the check boxes:

1. Open the Screen Builder and select the Check Box tool. (In FoxPro for

   MS-DOS, choose Check Box from the Screen menu.)

2. Create three check boxes on the screen with the first one having the
   variable check1, the second one having the variable check2, and the
   third one having the variable check3.

3. In the VALID clause of the first check box, type in this code:

      IF check1=1
         SHOW GET check2 DISABLED
         SHOW GET check3 DISABLED
      ELSE
         SHOW GET check2 ENABLED
         SHOW GET check3 ENABLED
      ENDIF

4. In the VALID clause of the second check box, type in this code:

      IF check2=1
         SHOW GET check1 DISABLED
         SHOW GET check3 DISABLED
      ELSE
         SHOW GET check1 ENABLED
         SHOW GET check3 ENABLED
      ENDIF

5. In the VALID clause of the third check box, type in this code:

      IF check3=1
         SHOW GET check1 DISABLED
         SHOW GET check2 DISABLED
      ELSE
         SHOW GET check1 ENABLED
         SHOW GET check2 ENABLED
      ENDIF

After generating the screen and running it, click one of the check boxes. When one box is selected, the others will be disabled. To enable all the check boxes, click the box that is selected (the one that has an "X" in it). This will clear the box and make all the check boxes enabled until another check box is selected.

The variables check1, check2, and check3 will always have a value of 0 or 1. Therefore, when the variable is evaluated, this is how the IF statement is used enable or disable the check boxes.

Additional reference words: FoxMac FoxDos FoxWin 2.00 2.50 2.50a 2.50b checkbox KBCategory: kbprg KBSubcategory: FxtoolSbuilder

Keywords          : FxtoolSbuilder 
Version           : 2.50 2.50a 2.50b | 2.00 2.50 2.5
Platform          : MACINTOSH MS-DOS WINDOWS

Last Reviewed: May 1, 1996