I have 2 forms...and the textbox in the other form
- how can I get the typed text from the other form ?
- I tried this but it gives error.
- List item
var mainForm = Application.OpenForms.OfType<Form1>().Single();
mainForm.URL_BOX.Text();
CodePudding user response:
You should really post the error that you're getting. This wouldn't compile for me because you are referencing the URL_BOX
the wrong way. You can do this:
var mainForm = Application.OpenForms.OfType<Form1>().Single();
string urlBoxText = mainForm.Controls["URL_BOX"].Text;
Notice, also, that .Text
does not require parenthesis, as it is a property and not a method.