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. run a sub on one child form when an event occurs on another

run a sub on one child form when an event occurs on another

Scheduled Pinned Locked Moved Visual Basic
questionhelptutorial
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
    amatbrewer
    wrote on last edited by
    #1

    Ok, this one is driving me nuts, can someone tell me what I am doing wrong? I have a few MDI child forms open within a parent. I need to run a sub on one of the child forms when an event occurs on another. For example one of the child forms is created in the Load event of the MDIParent with the following: Dim ChildForm2 As New GraphFrm ChildForm2.MdiPrent = Me ChildForm2.Show() The GraphFrm contains a Sub UpdageGraphs() but when I attempt to call ChildForm2.UpdateGraphs() from the parent or any of the other MDI child forms I get an error that ChildForm2 is not declaired. How do I make this instance of the child form accessible to the Parent and other child forms?

    David Wilkes

    C 1 Reply Last reply
    0
    • A amatbrewer

      Ok, this one is driving me nuts, can someone tell me what I am doing wrong? I have a few MDI child forms open within a parent. I need to run a sub on one of the child forms when an event occurs on another. For example one of the child forms is created in the Load event of the MDIParent with the following: Dim ChildForm2 As New GraphFrm ChildForm2.MdiPrent = Me ChildForm2.Show() The GraphFrm contains a Sub UpdageGraphs() but when I attempt to call ChildForm2.UpdateGraphs() from the parent or any of the other MDI child forms I get an error that ChildForm2 is not declaired. How do I make this instance of the child form accessible to the Parent and other child forms?

      David Wilkes

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Use delegates to call methods between forms.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Use delegates to call methods between forms.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

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

        Thanks for the suggestion. I am still not completely clear on how to accomplish this. I am guessing I would have to define the delegate in the parent but not entirely sure when to assign the address of the function to the delegate.

        David Wilkes

        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