KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: A routine to hide or show objects in a form
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: September 3, 2009
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Hiding and showing objects is an effective way of increasing the flexibility and usability of a form. You can use a form with several objects that appear and disappear as the basis to provide different functionality from the same form. This approach can save you from creating too many different forms. The challenge is how to manage the objects that need to be hidden and shown without forgetting to incorporate new ones as you create them or edit them in a form. The following is a possible solution that only requires that you keep a level of consistency in the nomenclature you use to identify your objects:

Name your objects with a prefix that identifies the type of object. For example:

var_ for variables
button_ for buttons
label_ for text labels
border_ for borders

and so on... Keep in mind these are the Object Names. To use a routine that would hide certain objects, all you have to do is add another prefix to those objects you want to hide. The prefix can be either _showhide_ or more specific like _showhide_stage1_. For example:

var_showhide_
button_showhide_
label_showhide_
border_showhide_

Now all you have to do is to create a routine that uses those prefixes as the basis for what objects to show and hide. One important thing to remember, use the @ character to cover all the Objects you want to show or hide regardless of their names. As long as they start with the same prefix, it will work.

`Routine to hide objects

SET VISIBLE(*;"var_showhide_@";False)
SET VISIBLE(*;"button_showhide_@";False)
SET VISIBLE(*;"label_showhide_@";False)
SET VISIBLE(*;"border_showhide_@";False)


`Routine to show objects

SET VISIBLE(*;"var_showhide_@";True)
SET VISIBLE(*;"button_showhide_@";True)
SET VISIBLE(*;"label_showhide_@";True)
SET VISIBLE(*;"border_showhide_@";True)


If you create new Objects or edit the current ones, just remember to name them appropriately and the routine will always perform with any number of objects.