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. String and forms

String and forms

Scheduled Pinned Locked Moved C#
7 Posts 6 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.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

    string findme = txtfind.Text;

    thanks

    L K B D M 5 Replies Last reply
    0
    • S SRJ92

      hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

      string findme = txtfind.Text;

      thanks

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Form1.textVar.Text = findme;

      It's time for a new signature.

      modified on Saturday, June 19, 2010 8:12 AM

      1 Reply Last reply
      0
      • S SRJ92

        hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

        string findme = txtfind.Text;

        thanks

        K Offline
        K Offline
        Kristian Sixhoj
        wrote on last edited by
        #3

        You may wanna read this article: Passing Values between Forms in .NET 1.x with C# and VB.NET examples[^]

        :bob: Kristian Sixhoej I have noticed even people who claim everything is predestined, and that we can do nothing to change it, look before they cross the road. - Stephen Hawking

        1 Reply Last reply
        0
        • S SRJ92

          hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

          string findme = txtfind.Text;

          thanks

          B Offline
          B Offline
          Bigdeak
          wrote on last edited by
          #4

          There are a lot of possible ways and a lot of possible scenaries where you transfer a string from the one form to another. A very simple way is to associate the both form. That means, that form 1 has a instance for form 2 or reversed. So you have to make sure, that the properties from form 2 are public that you wan't to set from form 1. Here a small example of a association of two forms:

          public partial class Form1 : Form {
          
              public Form2 Form2 { get; set; }
          
              public Form1() {
                  InitializeComponent();
              }
          
              private void button1\_Click(object sender, EventArgs e) {
          
                  Form2.MyStringIfWantToSet = "Hello World";
              }
          }
          
          public partial class Form2 : Form {
          
              public string MyStringIfWantToSet {
                  get {
                      return textBox1.Text;
                  }
                  set {
                      textBox1.Text = value;
                  }
              }
          
              public Form2() {
                  InitializeComponent();
              }
          }
          

          [STAThread]
          static void Main() {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);

                  Form1 form1 = new Form1();
                  Form2 form2 = new Form2();
          
                  form1.Form2 = form2;
          
                  form2.Show();
          
                  Application.Run(form1);
              }
          

          I really hope i could help, sorry for my english...

          1 Reply Last reply
          0
          • S SRJ92

            hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

            string findme = txtfind.Text;

            thanks

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

            A tip[^] that will give you the code... An article[^] which will explain it and more.

            Dave

            If this helped, please vote & accept answer!

            Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
            BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)

            1 Reply Last reply
            0
            • S SRJ92

              hello, this may have been asked before but i am still having trouble with getting a string onto another form, i have searched google etc and still don't get it as many differant articles tell you differant things etc ... all i need to do is get my string from form 2 to form 1..... my code for my string .....

              string findme = txtfind.Text;

              thanks

              M Offline
              M Offline
              meilixueshan
              wrote on last edited by
              #6

              in form2 declare public property public string FindText; you can access this property, like this string find = from1.FindText;

              The big boss!

              S 1 Reply Last reply
              0
              • M meilixueshan

                in form2 declare public property public string FindText; you can access this property, like this string find = from1.FindText;

                The big boss!

                S Offline
                S Offline
                SRJ92
                wrote on last edited by
                #7

                Thank you !! :D :D

                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