Click here to Skip to main content
15,907,497 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings,

I have a critical issue here and I want some help.

I have an open form "Form1" that contains a label "Label1" and I have another form "Form2" that contains a button "Button2". What I need to do is to get a reference to the opened instance of Form1 so that I can update the attributes of Label1 and also make it invisible through the Button2_Click event in Form2.

Is this possible or not in Vb,Net 2005?


Please advise,

Thanks in advance....
Posted

Yes possible you need to create an Object of Form1 in form2.
ex.
VB
dim objectname as form1

and access label1 of form1 in Form2.as
ex.
VB
objectname.label1.text="Text"

and make anything you want to Label1 in form1.
 
Share this answer
 
Thanks Guys,

I got the solution myself and I will show it here for anyone to get benefit of it.

We have here:

Form1 is opened
Form1 contain Label1
Form 2
Form2 contain Button2

Then at the Load event of Form1 we write the following code:

Dim pForm2 as New Form2
If pForm2.ShowDialog=OK then
Label1.Visible=False
End If


Please contact me for any further details,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900