# Revision history [back]

Most controls have property EnableVisible, which is reflected in the Control dialog box value for Visible (Yes/No). I suggest grouping everything that should be hidden or displayed onto a Form and then iterating through the objects using a macro, toggling the EnableVisible property. SubForm objects don't have the necessary property so they must be excluded, and consider giving everything else that should not be hidden the same suffix at the end of their names-- those are excluded in the code example too if they end with the characters NoHide. This works pretty well in a function that can be used to toggle the EnableVisible property as follows:

Function ToggleShowHide(ShowHideVariable As Boolean )
RootForm = ThisComponent.Drawpage.Forms
MainForm = RootForm.getByName("MainForm")

i = 0

Do While i < MainForm.Count

If Right(MainForm.getByIndex(i).ServiceName, 4) <> "Form" And _
Right(MainForm.getByIndex(i).Name, 6) <> "NoHide" Then
MainForm.getByIndex(i).EnableVisible = ShowHideVariable
End If
i = i + 1

Loop
End Function


You would call the Function from another macro as follows: ToggleShowHide(False) or ToggleShowHide(True). One way would hide and the other would reveal.

Since it also is good form to move the cursor out of a control that is being hidden, you might also use the following at the same time you hide fields:

Cntrllr = ThisComponent.getCurrentController()
Cntrllr.getControl(MainForm.getByName("TargetField").SetFocus()


Please note that if you save the form after running the macro, it will save the then-current state of the shown/hidden controls, but all will be visible at the same time from the Edit mode.