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. C#
  4. Get Data from Lookup Form

Get Data from Lookup Form

Scheduled Pinned Locked Moved C#
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.
  • M Offline
    M Offline
    MJay
    wrote on last edited by
    #1

    I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code FormB formb = new FormB(); FormB.Show(); in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;)

    L 1 Reply Last reply
    0
    • M MJay

      I have a Main Form call FormA, FormA call a Lookup Form named FormB using following Code FormB formb = new FormB(); FormB.Show(); in FormB there is a textboxA to let the user to enter certain string value that need to passback to FormA and execute several statements in FormA when user press a button in FormB Any1 has any idea how to do that?my fren advise me to use delegate but i not very familiar with delegate coding structure, i greatly appreciated if any1 can provide the sample coding to do that;)

      L Offline
      L Offline
      luckykhalid
      wrote on last edited by
      #2

      There are many ways to accomplish your task. 1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you. 2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it. 3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it. You can use any of the above mentioned way. Hope it helps.

      Regards Khalid

      M 1 Reply Last reply
      0
      • L luckykhalid

        There are many ways to accomplish your task. 1) Best way would be to make a custom event. As you told that you dont know much about delegates so I think it will be even difficult for you. 2) Make a static method in FormA and call it from FormB's click event handler by either passing it this (FormB object) as an argument if FormB is not class variable in FormA. In that method get all the values from FormB and then you could just close FormB or even destroy it. 3)In the click event handler of FormB, get its Parent by FormB.Parent, this will yeild you the reference to FormA's object. Now you could do anything with it. You can use any of the above mentioned way. Hope it helps.

        Regards Khalid

        M Offline
        M Offline
        MJay
        wrote on last edited by
        #3

        Thanks man, i am trying the method u suggest :)

        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