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. Displaying Values of child form in the Parent ....

Displaying Values of child form in the Parent ....

Scheduled Pinned Locked Moved C#
question
5 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.
  • P Offline
    P Offline
    peter rankel
    wrote on last edited by
    #1

    Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?

    your peter

    M A 2 Replies Last reply
    0
    • P peter rankel

      Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?

      your peter

      M Offline
      M Offline
      Martin 0
      wrote on last edited by
      #2

      Hello, This article [^]from Colin Angus shows you all!

      All the best, Martin

      1 Reply Last reply
      0
      • P peter rankel

        Hi... I have two forms in my windows application. Form1 and Form2. In Form1 I have 1 Label and a button. In Form2 I have just a button. When clicking on this Form1 button I am opening Form2. In Form2 button Click event I have to hide the Form2 and have to show the value "HI" in the Form1 Label. To do this some one suggested me use delegates. Is this only way to do this?

        your peter

        A Offline
        A Offline
        abed almuti zalloum
        wrote on last edited by
        #3

        Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }

        P C 2 Replies Last reply
        0
        • A abed almuti zalloum

          Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }

          P Offline
          P Offline
          peter rankel
          wrote on last edited by
          #4

          Thank You

          your peter

          1 Reply Last reply
          0
          • A abed almuti zalloum

            Hi.. :) you can do thats by connect even form . --- Form1 --- private void button1_Click(object sender, System.EventArgs e) { Form2 FRM = new Form2(this); FRM.show(); } public void SetLabelValue(string MSG) { Label1.Text = MSG; } --- Form2 --- Form FRM1 = null; public Form2(Form1 frm) { // Required for Windows Form Designer support InitializeComponent(); this.FRM1 = frm ; } private void button1_Click(object sender, System.EventArgs e) { this.FRM1.SetLabelValue("HI"); FRM1.show(); }

            C Offline
            C Offline
            Colin Angus Mackay
            wrote on last edited by
            #5

            This is a poor solution because it couples the forms together. If you want to change the way your application works in the future it will be more difficult to make the modifications.

            Upcoming FREE developer events: * Developer Day Scotland Recent blog posts: * Different ways to add point data in SQL Server 2008 * Spatial References in SQL Server 2008 My website |

            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