I have a Form1.h and a Form2.h
Form1.h is already including Form2.h because i start Form2 by clicking a button in Form1. So how would i pass a variable from Form1.h to Form2.h
Here is an example of Form1.h
#include "Form2.h"
String^ str = "Hello World"; //This variable needs to be passed to Form2.h
//Other windows forms application code here
An example of Form2.h
//#include "Form1.h" this will cause an error
//How would i pass variable str to here?
//Other windows forms application code here
Edit:
This is how i fixed it
This is how i fixed it.
Form1.h
#include "Form1.h"
Form2^ frm = gcnew Form2;
frm->Username = "text here";//This passes the variables.
frm->Password = "other text";
Form2.h
public: String^ Username;
public: String^ Password;