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. C# :how to access textbox values of form1 from form2

C# :how to access textbox values of form1 from form2

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

    hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)

    senthil

    D G 2 Replies Last reply
    0
    • K kssknov

      hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)

      senthil

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

      There are many ways to acheive this, the easiest is to adjust the constructor for form2 to accept a textbox argument and store that as a variable in the form2 class in the constructor. Then you can access or change any of the form1.textbox properties from form2.

      1 Reply Last reply
      0
      • K kssknov

        hi all help me how to code in c# to pass the texbox values present in form1 to form2 for a button click event . i had coded lik this ina button click of form1 private void btnEdit_Click(object sender, EventArgs e) { frm2.Show();-----i had created frm2 object above this click event frm2.TextBox1=txtAreaName.Text;----> this code doesnt works. i mean here to pass the textbox value of form2 to textbox in form1. } pls help thank you :)

        senthil

        G Offline
        G Offline
        Giorgi Dalakishvili
        wrote on last edited by
        #3

        I suggest you read this article: http://www.codeproject.com/KB/dotnet/passingvaluesbetweenforms.aspx[^][^]

        #region signature my articles #endregion

        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