Home All Groups Group Topic Archive Search About

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

Author
17 Jun 2006 7:04 PM
Ali
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"

Author
18 Jun 2006 6:57 AM
Cor Ligthert [MVP]
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


Show quoteHide quote
"Ali" <A**@discussions.microsoft.com> schreef in bericht
news:F9A3F7E3-1A11-45E6-9710-4DB0EFB04A98@microsoft.com...
> 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"
Author
18 Jun 2006 8:44 AM
gene kelley
On Sun, 18 Jun 2006 08:57:19 +0200, "Cor Ligthert [MVP]"
<notmyfirstn***@planet.nl> wrote:

Show quoteHide quote
>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
Author
18 Jun 2006 9:17 AM
Herfried K. Wagner [MVP]
Show quote Hide quote
"gene kelley" <o***@by.me> schrieb:
>>\\\\
>>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


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'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
18 Jun 2006 12:02 PM
Cor Ligthert [MVP]
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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> schreef in bericht
news:OAlpKgrkGHA.4508@TK2MSFTNGP05.phx.gbl...
> "gene kelley" <o***@by.me> schrieb:
>>>\\\\
>>>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
>
>
> 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'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
18 Jun 2006 6:22 PM
Herfried K. Wagner [MVP]
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> schrieb:
> dohhhhhhhh
>
> You believe probably that I know that.

I'm sure you know that :-).

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
19 Jun 2006 12:08 PM
Grumpy Aero Guy
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 .....

--
Grumpy Aero Guy



Show quoteHide quote
"Ali" <A**@discussions.microsoft.com> wrote in message
news:F9A3F7E3-1A11-45E6-9710-4DB0EFB04A98@microsoft.com...
> 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"