c# - Pass variable from a form to other when closing -
i developing app requires close , open different winforms on time. faced problem, how can pass variable, in case serialport has been opened in initial form?
forms opened program.cs
application.run(new auth()); application.run(new main());
auth.cs code includes this:
serialport rcu = new serialport(); rcu.portname = textbox.text; //port name user input
and want use port in other form "main".
is there possibility this?
thanks
just ask auth
object in main
constructor , initialize them in order:
auth auth = new auth(); main main = new main(auth); application.run(auth); application.run(main);
then in main
can save object , property once set:
public main(auth auth) { authwindow = auth; } public auth authwindow {get; set;} // later.. authwindow.rcu
note though, 2 application.run
calls isn't way want go, create new auth
form , show moment main form loaded.
Comments
Post a Comment