Read variables between more than 2 forms
-
Done!
Thank you so much again!
-
Hi again!
Before i ask how to get the struct from another form. Now i'm trying to set values from a struct located in another form. The question is that the struct is too to make a set function for each variable...so i was thinking on this two options, considering that in Form2 I have a private struct that I want to change from Form1.
1- Try to send the complete struct. I declared a second struct in Form1, i modify the values and i send to Form2, once i receive there i change the values. But i don't have declared the struct in Form1 and also i think is a very ugly solution.
2-Try to make a pointer in Form1 to the struct located in Form2 to modify it.
Anyway both solutions are ugly, and i want to know a good way to do it.
Thanks.
-
I solved doing the 1st method.
Thanks
-
You mean you have 2 structs in both forms and they look the same? Why not just declare it once outside of both classes?
From design standpoint if both forms are reading and writing to it then it clearly doesn't belong to any of them. -
I got a private struct in a Form, and if i want to change it from another Form i have to implement a public function like "set_value", but if the struct is too big and i don't want to add let's say 200 functions, i need to do something diferent. Finally i create a temporal struct in form1, after i modify the values i want, and finally i send this struct to the form2 where is declared the struct i wanted to modify at the begining.
If i declare outside i can't access because is private.
For sure there are many ways and better but this is the best i could done actually...