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. how to access the data stored in one form's control into other form belonging to the same project in C#

how to access the data stored in one form's control into other form belonging to the same project in C#

Scheduled Pinned Locked Moved C#
csharptutorial
7 Posts 5 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.
  • K Offline
    K Offline
    kalaveer
    wrote on last edited by
    #1

    hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.

    M A C W 4 Replies Last reply
    0
    • K kalaveer

      hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.

      M Offline
      M Offline
      M LN Rao
      wrote on last edited by
      #2

      Is it a Web Application or Windows Application?

      Intelligence is measured by common sense not by how many scholarly books you read.

      1 Reply Last reply
      0
      • K kalaveer

        hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.

        A Offline
        A Offline
        atulonweb hotmail com
        wrote on last edited by
        #3

        Declare control on form1 as public,these will be available on another form via object of form1 Atul kumar

        C 1 Reply Last reply
        0
        • K kalaveer

          hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.

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

          This is asked so often, I keep meaning to write an article on it.

          kalaveer wrote:

          i created an instance of form1 in form2

          That won't help, it's a different instance to the one that has the data you need You can pass the right instance of form1 to form2 as a parameter, or, better yet, use delegates to pass data between forms.

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

          A 1 Reply Last reply
          0
          • C Christian Graus

            This is asked so often, I keep meaning to write an article on it.

            kalaveer wrote:

            i created an instance of form1 in form2

            That won't help, it's a different instance to the one that has the data you need You can pass the right instance of form1 to form2 as a parameter, or, better yet, use delegates to pass data between forms.

            Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

            A Offline
            A Offline
            atulonweb hotmail com
            wrote on last edited by
            #5

            hi yes he is right. u would be able to access information of ur control as creating an object would create new instance of form1 i just told that declaring a control as public would make that control accessible in another form..But to pass value u need to use delegate to communicate between them. cheers.

            1 Reply Last reply
            0
            • A atulonweb hotmail com

              Declare control on form1 as public,these will be available on another form via object of form1 Atul kumar

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

              Yes, when I write my article, I will cover this approach. It's very nasty, you should never do this. At a minimum, expose properties that get ( for example ) the text of a textbox, but not the textbox itself. This isn't VB, we're supposed to know about OO.

              Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog

              1 Reply Last reply
              0
              • K kalaveer

                hi i have a treeview control in one form which has some nodes and i need to display them as a list in some other form's combobox control and these two forms belonging to the same project i created an instance of form1 in form2 but its not showing the controls associated with form1 with my instance object. please suggest how to get the data of form1 into form2 thanks in advance.

                W Offline
                W Offline
                wenyuan
                wrote on last edited by
                #7

                hmm.. It's a interesting case . hz_luyg@hotmail.com:):-D:laugh:;):laugh: luyuguo

                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