How to hide a component at runtime?
Asked Answered
O

1

6

Using IntraWeb 14.1 and Delphi Berlin, I'm creating and parenting a frame inside a IWRegion like this:

 Page := TFrame.Create(Self);
 Page.Parent := UserSession.Body_Region;

where UserSession.Body_Region; is decleared as Body_Region: TIWRegion; in UserSessionUnit to pass that region from form to form at runtime, and all works fine.

The problem is that I want to hide the Frame loaded inside the UserSession.Body_Region at runtime which is UserSession.Main_Body_Region.Component[0]; but I couldn't do it.

I've tasted it with

(UserSession.Main_Body_Region.Component[0] as TFrame).hide;

or

(UserSession.Main_Body_Region.Component[0] as TFrame).Visible:= false;

but it's not working! also there is no errors!

is there any other way to do so or did I miss something here?

Oringas answered 29/9, 2017 at 14:52 Comment(4)
I've tried it with {Visible} but I've tried the {Enable} to check if this code responds or not and past it here by mistake, so in both case {Visible/Enable} its not working.Oringas
Perhaps setting property RenderInvisibleControls: Boolean; (of TIWRegion) False will help? See the docsStuartstub
You r right, I've set the property RenderInvisibleControls to false and the code started to work like a charmOringas
I think this can be beneficial to know for other users too, so I made a proper answer about it.Stuartstub
S
6

Although the documentation says that the

TIWRegion control is the IntraWeb equivalent of the TPanel from VCL.

it has a difference that is important to consider:

property RenderInvisibleControls: Boolean; inherited from TIWBaseContainer

The documentation describes it as

Use this property to inform that any control that has Visible = False when the container it is rendered will also be rendered along with the visible controls. This is particulary useful when you need to change the visibility of controls using Async events.

IOW, setting this property to False will stop child components with Visible = False from being rendered.

Stuartstub answered 29/9, 2017 at 18:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.