How to check absolute control visibility and how t

2019-07-13 18:00发布

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.

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

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. Is there a way to be notified for visibility changes without recursively listening parent visibility changes?

  2. 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?

Thanks.

1条回答
我想做一个坏孩纸
2楼-- · 2019-07-13 18:19

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

查看更多
登录 后发表回答