I've decided to write this tutorial to explain how to access controls on different form, a popular topic of discussion.
The basic formatForm.Control.Property Name of Form
. e.g. Form2 Name of Control
. e.g. Label Name of Property
e.g. TextExampleStart a new Windows Form Application.
To Form1
Add a textbox
Add a button
Add a label
Now add a new Form, to this form
Add a textbox
Add a button
Add a label
Double click on Form2 Button
vb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Take the contents of the textbox on this form and put it the label on the other form
Form1.Label1.Text = Me.TextBox1.Text'
' Me.Textbox1 is used because VB.Net can't use name of the form of which this control is a part of.
End Sub
Now go back to Form1 double click on the button
vb
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Take the contents of the textbox on this form and put it the label on the other form
Form2.Label1.Text = Me.TextBox1.Text
' Me.Textbox1 is used because VB.Net can't use name of the form of which this control is a part of.
End Sub
Double click on Form1
vb
This post has been edited by AdamSpeight2008: 19 Jul, 2008 - 08:32 AM