Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

C# Get TextBox Entry in other forms

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();

The Error

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading