Live Chat Icon For mobile
Live Chat Icon

I have two forms. How can I access a textbox on one form from the other form

Platform: WinForms| Category: Form

One way to do this is to make the TextBox either a public property or a public field. Then you will be able to access it through the instance of its parent form. So, if TextBox1 is a public member of FormA and myFormA is an instance of FormA, then you can use code such as

[VB.NET]
  Dim strValue as String = myFormA.TextBox1.Text

[C#]
  string strValue = myFormA.TextBox1.Text;

anywhere myFormA is known. Here is a VB project illustrating this technique.

Share with

Share on twitter
Share on facebook
Share on linkedin

Related FAQs

Couldn't find the FAQs you're looking for?

Please submit your question and answer.