tekgod01 Posted July 26, 2004 Posted July 26, 2004 Form1 has Label1, Label2, Label3, Label4, etc. When the user clicks on one of the labels, it calls up Form2, which has Labelx, Textbox1, and Button1. If Label1 was clicked, Form2 will have a title (aka, Form2.Text) "See" If Label2 was clicked, Form2 will have a title "Spot" If Label1 was clicked, Labelx will have the text "Enter See" If Label2 was clicked, Labelx will have the text "Spot Run" When the user clicks on Button1, the text entered into Textbox1 will fill in the text of the label that was clicked. I can change the text for Form2, no problem. I can change Labelx, no problem. I just can't bring the text back to Form1 to fill in Label1. Any suggestions? [edit] Almost forgot. Form1 is never hidden or anything. Form2 just pops up in front of Form1 and then closes when the user clicks on Button1. Form1 never moves. [/edit] Quote
mocella Posted July 27, 2004 Posted July 27, 2004 One quick solution is to change the definitions of your Form2 UI components from "private" to "protected internal" in scope - then you can get at them from Form1. Otherwise, you can set up properties in Form2 that just return the appropriate values from the fields you want Form1 to see. Quote
krinpit Posted July 27, 2004 Posted July 27, 2004 I can change the text for Form2, no problem. I can change Labelx, no problem. I just can't bring the text back to Form1 to fill in Label1. Any suggestions? In Form2 you could utilise the following Dim frmCallingForm As Object Public Sub New(ByRef frmCallingForm As Form) 'This is a constructor which should be called with: Dim frm As New Form2(Me) MyBase.New() 'This call is required by the Windows Form Designer. InitializeComponent() Me.frmCallingForm = frmCallingForm End Sub Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click Me.frmCallingForm.Label1.Text = Me.Textbox1.Text End Sub Quote
tekgod01 Posted July 27, 2004 Author Posted July 27, 2004 Thank you both. It took some time to figure out what either of you were saying (I'm still pretty new to this - this is my third program). I finally figured out krinpit's post but you forgot to mention that I needed to make the control on Form1 public. Again, thank you both. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.