HighTechTalks DotNet Forums  

Variable

Dotnet Framework (WinForms) microsoft.public.dotnet.framework.windowsforms


Discuss Variable in the Dotnet Framework (WinForms) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
mgalesic
 
Posts: n/a

Default Variable - 02-09-2005 , 03:37 PM






In VB.net
How could I access variable in Form2 declared in Form1.
Thanks!

Reply With Quote
  #2  
Old   
Herfried K. Wagner [MVP]
 
Posts: n/a

Default Re: Variable - 02-09-2005 , 03:56 PM






"mgalesic" <mgalesic (AT) foi (DOT) hr> schrieb:
Quote:
How could I access variable in Form2 declared in Form1.
What you need in 'Form2' is a reference to your instance of 'Form1'. You
can pass the reference to 'Form1' in a property when showing 'Form2' from
'Form1':

Code for 'Form1':

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

Code for 'Form2':

\\\
Private m_Form1 As Form1

Public Property Form1() As Form1
Get
Return m_Form1
End Get
Set(ByVal Value As Form1)
m_Form1 = Value
End Set
End Property
///

You can access 'Form1''s properties inside 'Form2' with 'Me.Form1', for
example, 'Me.Form1.Button1.Text = "Bla"'.

Providing a reference to an application's main form
<URL:http://dotnet.mvps.org/dotnet/faqs/?id=accessmainform&lang=en>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.