Updating UI of another form

L

lucaoscar

Hi all,

as you can see from the level of my question, i am pretty new to c# and
programming in general.

situation: i would like to update the UI of a form (main form of my
application) from a second form (which was called from the first).
Ideally when a button on the second form is pressed, the first one
(main form) should update/refresh its UI.

But it would be also fine to have the first form refreshing when the
second form is closed/disposed.

Can you help me please? Thanks in advance.

Luca
 
J

Joanna Carter [TeamB]

<[email protected]> a écrit dans le message de (e-mail address removed)...

| as you can see from the level of my question, i am pretty new to c# and
| programming in general.
|
| situation: i would like to update the UI of a form (main form of my
| application) from a second form (which was called from the first).
| Ideally when a button on the second form is pressed, the first one
| (main form) should update/refresh its UI.
|
| But it would be also fine to have the first form refreshing when the
| second form is closed/disposed.

Try adding an event to the second form and catching it in a handler on the
first form. Hook up the handler after creating the second form but before
showing it.

Joanna
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

There are several ways of doing this:

- Pass a reference to the first form in the constroctor of the second. then
you should declare some public methods in Form1 they will do the update on
it, this method will be called from Form2.

- Make Form2 declare some events that Form1 can subscribe to and update its
UI as needed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top