如何检测控件是否对用户可见?我有一个控件,显示应用程序的状态,我希望它只有在用户看到它时才更新(它的值要更新,例如,增加进度条的值,或更改标签的Text属性).如果用户已将包含此控件的表单最小化,或者另一个表单与此控件重叠,则无需更新它.如果控件不可见,我只是不想做额外的计算.另外,如何检测隐藏/显示此控件的事件?
我的表单层次结构是这样的:
Form -> TableLayoutOne -> TableLayoutTwo -> Panel -> ListBox
Run Code Online (Sandbox Code Playgroud)
在ListBox的MouseMove事件中,我有这样的代码:
Point cursosPosition2 = PointToClient(new Point(Cursor.Position.X, Cursor.Position.Y));
Control crp = this.GetChildAtPoint(cursosPosition2);
if (crp != null)
MessageBox.Show(crp.Name);
Run Code Online (Sandbox Code Playgroud)
MessageBox向我显示"TableLayoutOne",但我希望它向我显示"ListBox".我的代码在哪里,我错了?谢谢.