禁用父面板,同时保持子面板启用 [英] Disable Parent Panel, while keeping child panel enabled

查看:228
本文介绍了禁用父面板,同时保持子面板启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个WinForms应用程序,我有一个巨大的面板在里面。而该小组里面是一堆东西,包括第二,微小的面板。

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.

当某个事件发生时,我想了大量的面板,成为启用=假的,我还是想的小面板被激活。我能做到这一点?我试图刚刚重新启用的小面板后,我已经停用​​了大量的面板,但没有worky。

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;

tinyPanel.Parent =这一点;

但是,这只是让tinyPanel消失了。

But, that just makes tinyPanel disappear.

推荐答案

不,这是不可能的。 所有的子控件被禁用时,他们的父母被禁用。这是简单的Windows是如何工作的;你不会是能够改变它。

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.

您需要找到解决您的问题以不同的方式。重新养育控制的的一种选择,但你要做到这一点是不正确。你需要从<一个移除href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx"><$c$c>Controls收集为大规模面板,然后将其添加到控件集合表单。然后你就可以独立地改变两个控件的启用状态。

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.

这篇关于禁用父面板,同时保持子面板启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆