简体   繁体   中英

C# how to pass variables from form to userControl and viceversa

being a beginner of C # (WinForm) I am making graphical interfaces using a form inside which there is a container panel, in it at runtime I am going to open various user controls, which for me represent the various graphical pages. First of all I would like to know if this is a good method to manage graphical interfaces, or if there are better ones.

Then I would like to understand what is the best way to pass the data between the main form and the usercontrol pages. I usually instantiate the objects as static, so that I can also see them from the userControls ...

Thanks

Create properties in your user control so as to access the underlying data. I would advise against exposing any nested control in your user control.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM