Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. accessing form member from another form

accessing form member from another form

Scheduled Pinned Locked Moved Visual Basic
tutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    acecase
    wrote on last edited by
    #1

    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

    S 1 Reply Last reply
    0
    • A acecase

      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

      S Offline
      S Offline
      steff kamush
      wrote on last edited by
      #2

      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:

      A 1 Reply Last reply
      0
      • S steff kamush

        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:

        A Offline
        A Offline
        acecase
        wrote on last edited by
        #3

        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..

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups