我已经创建了C#Windows应用程序中有两个用户控件。
I have created a Windows application in C# with two user controls.
当加载窗体第一个用户控件加载(并显示),当我点击下一步我打开第二个用户的控制。
When the form loads first user control is loaded(and shown)and when I click Next I load second user control.
现在我想调用该用户控制的方法,一旦用户控件是可见的。
Now I want a method from this user control to be called once the user control is visible.
我不能这样做。如果上午从调用Load事件的方法,它被发射前的控制是可见的。
I am not able to do so. If am call the method from Load event it gets fired before the control is visible.
是否有人可以指导我应该怎么做的方法的调用之后的控制是可见的。
Can someone please guide me on how should I make the call of method after the control is visible.
您可能需要使用的 VisibleChanged在事件。
You probably want to use the VisibleChanged event.
例如:
userControl2.VisibleChanged += new EventHandler(this.UserControl2VisibleChanged);
private void UserControl2VisibleChanged(object sender, EventArgs e)
{
if(userControl2.Visible)
{
CallMyMethodIWantToRunWhenUserControl2IsVisibleHere();
}
}