How can I change a property of a control form Form2 ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello
How can I change a property of a control from From2 but the control is in
Form1.
I wrote these code in Form2 but didnt work.

Dim f as new form1
f.Textbox1.Text = "hello world"
 
Ali

\\\\
Public Class Form1
Sub ShowOtherForm()
Dim frmPrint As New Form2
frmPrint.Owner = Me
frmPrint.Show()
End Sub
///


Now you can use in your second form
\\\
WhatINeed = me.owner.Textbox1.Text
///
I hope this helps,


Cor
 
Ali

\\\\
Public Class Form1
Sub ShowOtherForm()
Dim frmPrint As New Form2
frmPrint.Owner = Me
frmPrint.Show()
End Sub
///


Now you can use in your second form
\\\
WhatINeed = me.owner.Textbox1.Text
///
I hope this helps,


Cor

I've seen this answer posted previously. However, I can't see how
this line could possibly work:
WhatINeed = me.owner.Textbox1.Text

The line should be:
WhatINeed = Me.Owner.Controls("TextBox1").Text

Gene
 
gene kelley said:
I've seen this answer posted previously. However, I can't see how
this line could possibly work:
WhatINeed = me.owner.Textbox1.Text

The line should be:
WhatINeed = Me.Owner.Controls("TextBox1").Text


The line 'Me.Owner.TextBox1.Text' only works with 'Option Strict Off'. If
you have turned this option on, use 'DirectCast(Me.Owner,
Form1).TextBox1.Text'.
 
dohhhhhhhh

You believe probably that I know that.

I had changed somebody else (who had this not in it) just quick in that was
even another error from me.

Thanks

Cor
 
I use a factory class for this and store instances of the forms in this
class via properties....

Has worked for me well thus far .....
 
Back
Top