Controls on another form

M

Mr.D

I VB6 I did this:
Form2.Text1.Text = Form1.Text1.Text

How do I accomplish this in VB.Net?
 
H

Herfried K. Wagner [MVP]

* "Mr.D said:
I VB6 I did this:
Form2.Text1.Text = Form1.Text1.Text

How do I accomplish this in VB.Net?

You will have to store a reference to the other form instance somewhere,
for example in a public property of a module.
 
M

Mr.D

Herfried K. Wagner said:
You will have to store a reference to the other form instance somewhere,
for example in a public property of a module.

I don't quite understand.
Can you give me some example code please?
 
H

Herfried K. Wagner [MVP]

* "Mr.D said:
I don't quite understand.

Can you give me some example code please?

You will have to pass a reference to the form to the 2nd form, for
example in a property. You can set this property before showing the
form.

Quick and Dirty:

In Form2:

\\\
..
..
..
Private m_MyForm1 As Form1
..
..
..
Public Property MyForm1() As Form1
Get
Return m_MyForm1
End Get
Set(ByVal Value As Form1)
m_MyForm1 = Value
End Set
End Property
..
..
..
///

Usage:

\\\
Dim f As New Form2()
f.MyForm1 = Me
f.Show()
///
 
M

Mr.D

Herfried K. Wagner said:
In Form2:
Private m_MyForm1 As Form1
.
Public Property MyForm1() As Form1
Get
Return m_MyForm1
End Get
Set(ByVal Value As Form1)
m_MyForm1 = Value
End Set
End Property
.
Usage:

Dim f As New Form2()
f.MyForm1 = Me
f.Show()

Thank you so much indeed.
Works like a charm :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top