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 I can Show the Value of Textbox in another form in C sharp?

How I can Show the Value of Textbox in another form in C sharp?

Scheduled Pinned Locked Moved C#
csharphelpquestion
5 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.
  • I Offline
    I Offline
    ishaq shinwari
    wrote on last edited by
    #1

    Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!

    P V 2 Replies Last reply
    0
    • I ishaq shinwari

      Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Is this other form open already? Do you want the value to be displayed when the user clicks a button, or is it to be updated as the user types? You need to provide more information before anyone can offer useful help.

      Forgive your enemies - it messes with their heads

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      I 1 Reply Last reply
      0
      • P Pete OHanlon

        Is this other form open already? Do you want the value to be displayed when the user clicks a button, or is it to be updated as the user types? You need to provide more information before anyone can offer useful help.

        Forgive your enemies - it messes with their heads

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        I Offline
        I Offline
        ishaq shinwari
        wrote on last edited by
        #3

        Yes, this form is already open, I wants to link it with this. And i want to open the this by button click,

        P 1 Reply Last reply
        0
        • I ishaq shinwari

          Yes, this form is already open, I wants to link it with this. And i want to open the this by button click,

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          The common way to do this is to have an event in your code that looks something like this:

          public event EventHandler<string> MyText;

          protected void OnMyTextChanged()
          {
          EventHandler<string> handler = MyText;
          if (handler == null)
          {
          return;
          }
          handler(this, new TextChangedEventArgs(textBox.Text));
          }

          Then, all you need do is subscribe to the event in the second form, and it will automatically receive the string whenever you raise this event (which you would trigger from your button click event). Note that TextChangedEventArgs is a custom event args class defined like this:

          public class TextChangedEventArgs : EventArgs
          {
          public TextChangedEventArgs(string text) : base()
          {
          MyText = text;
          }
          public string MyText { get; private set; }
          }

          Forgive your enemies - it messes with their heads

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          1 Reply Last reply
          0
          • I ishaq shinwari

            Hi, I have a textbox, and i want to show the value of this textbox in another window form? Any one can help me? Thanks!

            V Offline
            V Offline
            Varun Sareen
            wrote on last edited by
            #5

            Use the customeventhandler functionality of .net

            Varun Sareen (Dot Net Developer)

            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