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?

Dreamer64
  • 923
  • 2
  • 13
  • 30
  • 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. – Dreamer64 Sep 29 '17 at 15:06
  • 1
    Perhaps setting `property RenderInvisibleControls: Boolean;` (of `TIWRegion`) `False` will help? See the [docs](http://docs.atozed.com/docs.dll/intraweb%20components/standard/TIWRegion.html) – Tom Brunberg Sep 29 '17 at 15:48
  • You r right, I've set the property `RenderInvisibleControls` to false and the code started to work like a charm – Dreamer64 Sep 29 '17 at 17:14
  • 1
    I think this can be beneficial to know for other users too, so I made a proper answer about it. – Tom Brunberg Sep 29 '17 at 18:03

1 Answers1

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.

Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54