|
-
Jul 21st, 2003, 03:10 PM
#1
Thread Starter
Junior Member
Simple VB.NET control question
Hi everyone,
I know that there is probably a very easy way to do this, but I have yet to figure it out. Here is the basic scenario:
Form1 contains Label1
Form1 creates an instance of Form2
Form2 contains Button1
Form2.Button1.onClick needs to set Form1.Label1.Text = "something" (without creating a new instance of Form1 because I need to keep all other values as-is).
Your help is appreciated. Thanks!
-Chris
-
Jul 21st, 2003, 03:32 PM
#2
I am thinking of using a module and using a public variable.
Hmm..
I'm going to have to do something like this with my program soon. I got a form that needs to manipulate, find and goto an area within the textbox on the other form.
-
Jul 21st, 2003, 03:58 PM
#3
You should try searching first:
http://www.vbforums.com/showthread.p...hreadid=251839
http://www.vbforums.com/showthread.p...hreadid=249630
Although these do different things they show how to interact with multiple instance of forms, which is the same situation you have. You need to work with an existing instance of a form.
-
Jul 21st, 2003, 04:21 PM
#4
Thread Starter
Junior Member
I found the solution to my problem. In case anyone is interested:
VB Code:
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim f2 As New Form2()
f2.Create(Me)
End Sub
End Class
Public Class Form2
Private m_fParent As Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
m_fParent.Label1.Text = "something"
End Sub
Sub Create(ByVal fParent As Form1)
m_fParent = fParent
Me.Show()
End Sub
End Class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|