Tried this: ---------------------------------------------Pure-FYI-OK-to-Skip-It---------
Form1^ myForm = safe_cast<Form1^>(sender);
It complies, then crashes when button is clicked:
Unable to cast object of type 'System.Windows.Forms.Button' to type 'FormNamespace.Form1'
In case you didn't know... FindForm() is a .NET function: Control.FindForm Method (System.Windows.Forms)
I'm OK with using it to hook the parent form.
As for:-------------------------------------------------Please-Dont-Skip-This---------
Code:
TextBox^ tb = safe_cast<TextBox^>(myForm->Controls["textBox1"]);
if(!tb){ MessageBox::Show("Not tb","Alert"); return; } // I added this
Yep, when I click the button it says "Not tb"... but, since I have textBox1 inside splitContainer1, I tried:
Code:
SplitContainer^ sc = safe_cast<SplitContainer^>(myForm->Controls["splitContainer1"]);
sc->SplitterDistance=200; // IT WORKS - YEAH!
So, how can I hook textBox1 - I tried and failed with:
Code:
TextBox^ tb = safe_cast<TextBox^>(sc->Controls["textBox1"]);
TextBox^ tb = safe_cast<TextBox^>(myForm->Controls["splitContainer1->textBox1"]);
TextBox^ tb = safe_cast<TextBox^>(myForm->Controls["splitContainer1::textBox1"]);
Ideas?