How to call a method after user control

I created a Windows application in C # with two user controls.

When the download form loads, the first user control loads (and displays), and when I click Next, I load the second user control.

Now I want the method from this user control to be called after viewing the user control.

I can not do it. If I call a method from the Load event, it fires before the control is visible.

Can someone help me find out how to make a method call after the control is visible.

+8
c # winforms desktop-application
source share
1 answer

You probably want to use the VisibleChanged event.

For example:

userControl2.VisibleChanged += new EventHandler(this.UserControl2VisibleChanged); private void UserControl2VisibleChanged(object sender, EventArgs e) { if(userControl2.Visible) { CallMyMethodIWantToRunWhenUserControl2IsVisibleHere(); } } 
+3
source share

Source: https://habr.com/ru/post/649942/


All Articles