How to use variable in another windows form? For example: This is Form 1 event button click. After clicking th button i want to apear "num" in textbox "Form2" form.
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{
int num = 10;
Form2^ f = gcnew Form2();
f->Show();
}
lets suppose that in form2 is textbox named "text"
private: System::Void Form2_Load(System::Object^ sender, System::EventArgs^ e)
{
text->Text = num;
}
Form2 doesnt see "num" variable. Im using c++/CLI (visual studio)
Try this instead:
private: System::Void button_Click(System::Object^ sender, System::EventArgs^ e)
{
int num = 10;
Form2^ f = gcnew Form2();
f->text->Text = num.ToString();
f->Show();
}