accessing form member from another form
-
Hey, I am trying to find a way to access the contents of a textbox in a child form from a control on the parent form and from other modules. Im sure this is simple and the info is out there all over the place but I have dug till I'm tired and can't find it. I found ALLOT of references on how to access parent objects from child forms but not the oposite. Specificly what I am trying to do is control the wordwrap option of a textbox object in the currently active child form. I have made the textbox of the child form public but still when I try to reference the object I get squigly lines and it can't see it. Most likely because while Im writeing the code the child doesn't exist or something of that nature. Heres what I tried. (the textbox I am referenceing is named textField) activeMdiChild.textField.wordwrap = true I get squiglies after the textField entry (because it doesn't exist yet I assume) Is it possible to control objects by referencing the activeMdiChild at all? In other words, is there any way to say (do "Xaction" to "Xobject" in the active mdi child form? Thank you
-
Hey, I am trying to find a way to access the contents of a textbox in a child form from a control on the parent form and from other modules. Im sure this is simple and the info is out there all over the place but I have dug till I'm tired and can't find it. I found ALLOT of references on how to access parent objects from child forms but not the oposite. Specificly what I am trying to do is control the wordwrap option of a textbox object in the currently active child form. I have made the textbox of the child form public but still when I try to reference the object I get squigly lines and it can't see it. Most likely because while Im writeing the code the child doesn't exist or something of that nature. Heres what I tried. (the textbox I am referenceing is named textField) activeMdiChild.textField.wordwrap = true I get squiglies after the textField entry (because it doesn't exist yet I assume) Is it possible to control objects by referencing the activeMdiChild at all? In other words, is there any way to say (do "Xaction" to "Xobject" in the active mdi child form? Thank you
acecase i don c the problem. if Form1 is MDIParent n Form2 is MDIChild in the same project, Form2.Modifier defaults to Friend n this is enough. this code works for me: '//in Form1 class - note code setting TextBox1.Multiline Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim NewMDIChild As New Form2() 'Set the Parent Form of the Child window.. NewMDIChild.MdiParent = Me 'Display the new form.. NewMDIChild.Show() NewMDIChild.TextBox1.Multiline = True NewMDIChild.TextBox1.Height = 50 NewMDIChild.TextBox1.Text = "fkuhzsdhflkxh" & vbCrLf & "79230570239" End Sub this can b done in other events eg. menu_click, button_click, etc :rose::rose:
-
acecase i don c the problem. if Form1 is MDIParent n Form2 is MDIChild in the same project, Form2.Modifier defaults to Friend n this is enough. this code works for me: '//in Form1 class - note code setting TextBox1.Multiline Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim NewMDIChild As New Form2() 'Set the Parent Form of the Child window.. NewMDIChild.MdiParent = Me 'Display the new form.. NewMDIChild.Show() NewMDIChild.TextBox1.Multiline = True NewMDIChild.TextBox1.Height = 50 NewMDIChild.TextBox1.Text = "fkuhzsdhflkxh" & vbCrLf & "79230570239" End Sub this can b done in other events eg. menu_click, button_click, etc :rose::rose:
I'm sorry for not being more specific. You're rite, there is no problem doing that to the form before or when you instantiate it. What I should have been more cleare about was that I needed to access the childforms objects and properties for specific child forms that enheritted from that form and were currently showing. Someone on google helped me out on this though and frankly I am ashamed at how simple it is. You use DirectCast e.g DirectCast(me.mdiparent.ActiveMdiChild, _ form2).textBox1.WordWrap = true to turn wordwrap on for the textbox in the currently active child form of type form2. 2 U.S. coins equal 30 cents and one is NOT a nickle. Hmm..