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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Getting Data From Calling Form

Getting Data From Calling Form

Scheduled Pinned Locked Moved C#
c++csharpquestion
3 Posts 3 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.
  • J Offline
    J Offline
    J Guds
    wrote on last edited by
    #1

    I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University

    K S 2 Replies Last reply
    0
    • J J Guds

      I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University

      K Offline
      K Offline
      Kodanda Pani
      wrote on last edited by
      #2

      Hi Guds, 1) You can pass the instance of the main form to the child form and can access the values from that object. 2)You can use delegate to access the values of the main form in the child form. Thanks and Regards SGS

      1 Reply Last reply
      0
      • J J Guds

        I'm pretty green at C#, and what I'm trying to do is what is described in C++, my native language, is sending and retriving data from a modeless box. What I have is a main dialog box/form that calls another dialog box/form, and I can't seem to location the method of getting data from the main form to the newly called form. If someone could point me to a simple app that uses this function or just describe what I'm looking for in the parent call, that would be great. Thanks J Guds Masters Student Kansas University

        S Offline
        S Offline
        S Senthil Kumar
        wrote on last edited by
        #3

        It's fairly simple, just pass the reference to the main form to the modeless form. Something like

        class MainForm : Form
        {
        public void ShowForm()
        {
        ChildForm f = new ChildForm(this);
        f.Show();
        }
        }

        class ChildForm : Form
        {
        MainForm mainForm;
        public ChildForm(MainForm f)
        {
        mainForm = f;
        }

        void SomeFunc() { int data = mainForm.data; }
        }

        Regards Senthil _____________________________ My Blog | My Articles | WinMacro

        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