Link to home
Start Free TrialLog in
Avatar of jamesdean666
jamesdean666

asked on

C# Refresh Underlying form data

I am working on a C# winforms application.

I have Form1 and Form2.

On Form1, I have Label1.  I open Form2 by clicking on a button on Form1 (Form1 remains open as well).

When I close Form2, or perform another method on Form2, I would like to refresh the text in Form1.Label1.

Can anyone help me with the code to do this.

Thanks.
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

you need to implement delegate and event in this case
in form2 closing event you will raise an event which will be handled by a hanlder for the event and delegate in form1
please go through the following link as its implemeting something similar to your requirements
https://www.experts-exchange.com/questions/23671134/How-do-I-update-a-control-on-formA-from-formB.html
https://www.experts-exchange.com/questions/23736959/Communication-between-UserControls-and-Winforms.html
https://www.experts-exchange.com/questions/23795439/Need-to-update-textbox-on-the-main-form-from-another-class.html

all the links have my reference in them :)
Cheers - Ragi
Avatar of klace06
klace06

hi suggestion why dont u use events when u close form 2 fire an event which is handled in form1
when the event is fired , the event handler will have code to change the label1's text
you dont need delegates only if u are passing event values can be done without delegates
Avatar of jamesdean666

ASKER

I am still struggling with this.. Can you please provide some code?
ASKER CERTIFIED SOLUTION
Avatar of Anurag Thakur
Anurag Thakur
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
can you post the code snippet that you have and i can modify it to work
Thnx.