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. I need Help passing data back and forth between Windows forms

I need Help passing data back and forth between Windows forms

Scheduled Pinned Locked Moved C#
tutorialcsharpwinformscomhelp
4 Posts 4 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
    Member_4394319
    wrote on last edited by
    #1

    Hi I am trying to pass data back and forth windows forms but I am having trouble. What I am trying to do is this: I have a mainForm that has 2 textboxes called plainText and ChiperText. This main form also has a menu bar of different algo to choose from(for instance shift Chiper). When shift chiper is clicke id launched a new form(shiftchiper.cs). It has some options and it also have a toolbar with Encrypt and decrypt. When encrypt is hit I want to take the data from mainForm PlainText textbox and encrypt it. Once encrypted send it back to the mainForms chiperText box. If they hit decrypt it's the same thing just reversed. By using this tutorial( I used the property way) http://www.codeproject.com/KB/cs/pass\_data\_between\_forms.aspx I been able to send the PlainText data to the shiftChiper form and encrypt it. What I can't do is send the new encrypted data back to the ChiperText textbox in the mainForm. So anyone know how to do this? I simple example would be nice. It can be just 2 textboxes on one form and a button. when the button is clicked a form2 is made and it sends over one of the textboxes. One form2 it can have a button when clicked it sends the data that was sent back to form1. I am doing it in C# by the way.

    J N D 3 Replies Last reply
    0
    • M Member_4394319

      Hi I am trying to pass data back and forth windows forms but I am having trouble. What I am trying to do is this: I have a mainForm that has 2 textboxes called plainText and ChiperText. This main form also has a menu bar of different algo to choose from(for instance shift Chiper). When shift chiper is clicke id launched a new form(shiftchiper.cs). It has some options and it also have a toolbar with Encrypt and decrypt. When encrypt is hit I want to take the data from mainForm PlainText textbox and encrypt it. Once encrypted send it back to the mainForms chiperText box. If they hit decrypt it's the same thing just reversed. By using this tutorial( I used the property way) http://www.codeproject.com/KB/cs/pass\_data\_between\_forms.aspx I been able to send the PlainText data to the shiftChiper form and encrypt it. What I can't do is send the new encrypted data back to the ChiperText textbox in the mainForm. So anyone know how to do this? I simple example would be nice. It can be just 2 textboxes on one form and a button. when the button is clicked a form2 is made and it sends over one of the textboxes. One form2 it can have a button when clicked it sends the data that was sent back to form1. I am doing it in C# by the way.

      J Offline
      J Offline
      Jay Gatsby
      wrote on last edited by
      #2

      I think I know what you're talking about. let me see if I can help. Anything in public access space on the popup can be accessed by the main form from wherever the instance of the popup is. For example. on my main form named form1 I have a button that opens a popup named form2. in the button click event on form1's button I'd have something to the effect of PopupFormTypenameGoesHere form2 = new PopupFormTypenameGoesHere( params to send et all) form2.ShowDialogue(); Text = form2.someInfo; and in form2's close event I'd have someInfo = "hello world"; // or whatever This would cause form1's title (ie it's Text property) to be set to "hello world" after the popup had closed (or whatever someInfo was set to in that form) I hope that helps. One thing you should be careful with is the usage of Show() and ShowDialogue() - they are NOT interchangeable.

      -Gatsby

      1 Reply Last reply
      0
      • M Member_4394319

        Hi I am trying to pass data back and forth windows forms but I am having trouble. What I am trying to do is this: I have a mainForm that has 2 textboxes called plainText and ChiperText. This main form also has a menu bar of different algo to choose from(for instance shift Chiper). When shift chiper is clicke id launched a new form(shiftchiper.cs). It has some options and it also have a toolbar with Encrypt and decrypt. When encrypt is hit I want to take the data from mainForm PlainText textbox and encrypt it. Once encrypted send it back to the mainForms chiperText box. If they hit decrypt it's the same thing just reversed. By using this tutorial( I used the property way) http://www.codeproject.com/KB/cs/pass\_data\_between\_forms.aspx I been able to send the PlainText data to the shiftChiper form and encrypt it. What I can't do is send the new encrypted data back to the ChiperText textbox in the mainForm. So anyone know how to do this? I simple example would be nice. It can be just 2 textboxes on one form and a button. when the button is clicked a form2 is made and it sends over one of the textboxes. One form2 it can have a button when clicked it sends the data that was sent back to form1. I am doing it in C# by the way.

        N Offline
        N Offline
        nelsonpaixao
        wrote on last edited by
        #3

        do you need to use 2 forms? is there a critical reason? i don´t see it. i use (1) parent form/child form method or (2) the form + userforms (loaded in form) method but i don´t see how you can get it to work, i assume you did the same in both forms. i think it´s because the first owes the second. Are you using delegates? check articles here on those methods, you won´t get errors :( and look nicer

        nelsonpaixao@yahoo.com.br trying to help & get help

        1 Reply Last reply
        0
        • M Member_4394319

          Hi I am trying to pass data back and forth windows forms but I am having trouble. What I am trying to do is this: I have a mainForm that has 2 textboxes called plainText and ChiperText. This main form also has a menu bar of different algo to choose from(for instance shift Chiper). When shift chiper is clicke id launched a new form(shiftchiper.cs). It has some options and it also have a toolbar with Encrypt and decrypt. When encrypt is hit I want to take the data from mainForm PlainText textbox and encrypt it. Once encrypted send it back to the mainForms chiperText box. If they hit decrypt it's the same thing just reversed. By using this tutorial( I used the property way) http://www.codeproject.com/KB/cs/pass\_data\_between\_forms.aspx I been able to send the PlainText data to the shiftChiper form and encrypt it. What I can't do is send the new encrypted data back to the ChiperText textbox in the mainForm. So anyone know how to do this? I simple example would be nice. It can be just 2 textboxes on one form and a button. when the button is clicked a form2 is made and it sends over one of the textboxes. One form2 it can have a button when clicked it sends the data that was sent back to form1. I am doing it in C# by the way.

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          Envents and/or delegates are the answer. I posted a delegate sample here[^] previously.

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Expect everything to be hard and then enjoy the things that come easy. (code-frog)

          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