10

I have a WinForms app, and I have a massive Panel in it. And inside that Panel is a bunch of stuff, including a second, tiny panel.

When a certain event occurs, I want the massive panel to become Enabled = false, and I still want the tiny panel to be Enabled. Can I do this? I have tried to just re-enable the tiny panel after I've disabled the massive panel, but no worky.

Or, how can I make it so the tiny panel is "on-top of", but not "inside" the massive panel?

I took a wild guess and tried:

tinyPanel.Parent = null;

and tinyPanel.Parent = this;

But, that just makes tinyPanel disappear.

2 Answers2

16

No, this is not possible. All child controls are disabled when their parent is disabled. That's simply how Windows works; you're not going to be able to change it.

You need to find a different way of solving your problem. Re-parenting the control is an option, but the way you're trying to do it is incorrect. You need to remove it from the Controls collection for the "massive Panel", and then add it to the Controls collection for your form. Then you will be able to change the enabled state of both controls independently.

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
0

I don't think you can make a control enabled while the parent control is disabled.

Dyppl
  • 12,161
  • 9
  • 47
  • 68
  • Hmmm... So, maybe if I change the z-order of the tinyPanel, it may work? Or am I using my imagination too much –  Mar 19 '11 at 10:20
  • 3
    Z order has nothing to do with parent controls. They're orthogonal properties. – Cody Gray - on strike Mar 19 '11 at 10:25
  • @Cody Gray: you're most likely right, I think I messed up and got it mixed up with the order of docked controls like toolstrips. Fixing my answer now – Dyppl Mar 19 '11 at 12:31