Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to hide a component at runtime?

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?

like image 927
Dreamer64 Avatar asked Sep 29 '17 14:09

Dreamer64


1 Answers

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.

like image 167
Tom Brunberg Avatar answered Nov 14 '22 01:11

Tom Brunberg