Link to home
Start Free TrialLog in
Avatar of brettr
brettr

asked on

How to avoid being child of control?

I have a panel that displays only when a certain button is clicked.  While the panel is hidden, there are a couple of text boxes and labels that display.  The textboxes and labels sit on top of the panel.  Once the panel shows, I call bringtofront().  This hides the textboxes and labels.  It all works fine.

I drop a new textbox onto the form, not the panel.  Then I move it on top of the panel.  It should hide when the panel displays and vice versa.  Just as the above controls do.  The problem is that this new textbox acts like a child of the panel once I move it on top of the panel.  The textbox will now hide when the panel hides, rather than the other way around.  Why does that happen?
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

"I drop a new textbox onto the form, not the panel.  Then I move it on top of the panel."

When you move the TextBox over the Panel and let go, it becomes a child of the Panel.  The cursor changes to indicate this.  It places a small box under the arrow to show that the TextBox will be moved into the Panel.

If you want to position the TextBox without changing the container then use the Location() property and type in the x,y values manually.  This will keep the Form as the container.
Avatar of brettr
brettr

ASKER

That would make it difficult at design time.  I need good design time support for arranging controls that display while the panel is hidden.  

I've figured out how to do it.  Move the panel out of the way and arrange all of your controls that aren't children of the panel.  Then move the panel back on top of them.

You suggestion about location can be used at runtime to ensure the panel is always positioned properly.
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial