开发者

Disable Parent Panel, while keeping child panel enabled

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜