如何检查绝对控件的可见性以及如何通知绝对可见性的变化 [英] How to check absolute control visibility and how to be notified for changes of absolute visibility

查看:105
本文介绍了如何检查绝对控件的可见性以及如何通知绝对可见性的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的表单中有几个控件,并且我对这些控件进行了一些更改(文本,字体,背景色等)。仅当控件可见时,才需要进行我的更改。因此,我想停止对不可见的控件执行更改。我想继续更改控件,使它们再次变得可见。

I have several controls inside my form and I perform several changes (Text, Font, BackColor etc.) on these controls. My changes are necessary only if the controls are visible. So, I want to stop performing my changes on controls that are not visible. I want to keep changing my controls when they become visible again.

我可以使用Control.Visible和Control.VisibleChanged,但是对于我的目的,它们并不令人满意。

I can use Control.Visible and Control.VisibleChanged, however they are not satisfactory for my purpose.

问题是,当控件由于其父级变为不可见时(即,由于其父级变为不可见),VisibleChanged不会被触发。有趣的是,当控件再次变得可见时,它会被触发。

The problem is, VisibleChanged is not fired when control becomes invisible due to its parent (i.e. because its parent became invisible). Interestingly, it is fired when control becomes visible again.


  1. 是否可以通过通知方式更改可见性而无需递归地侦听父级可见性更改了吗?

  1. Is there a way to be notified for visibility changes without recursively listening parent visibility changes?

当在我的表单上放置另一个表单并且某些控件变得不可见时,我还想得到通知。我称之为绝对可见度。 (是否还有其他术语?)是否有可以用于此目的的事件?

I also want to be notified when another form is placed over my form and some of my controls become non-visible. I call this absolute visibility. (Is there another term for it?) Is there an event that I can use for this purpose?

谢谢。

推荐答案

您可以设置一个计时器,以检查控件上.Visible属性的状态,并在更改时触发事件

You could set up a timer that checks the state of the .Visible property on the control and fire an event when that changes.

这篇关于如何检查绝对控件的可见性以及如何通知绝对可见性的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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