Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event handling (Detect when hiding form)

Well normally I am quite good at figuring and researching problems without guidance however I have come across a snag. I am trying to create an "Event" with C# (which I have not done before) everything I have looked up has nothing to do with what I need.

I am trying to call a class on my main form when form2 is hidden. I found some code which was supposed to check to see if form2 closed - Either I didn't integrate it into my code properly or closing is different to hiding.

So just to clarify I want to run through the program like this:

  • Form1 runs
  • Click setting button on Form1 which opens Form2
  • Form2 opens where settings can be changed
  • Click the "Ok" button on Form2 (here is where I want Form1 to realise Form2 has been hidden
  • Hide form one and run a class called Refresh which refreshes button names and URLs
like image 830
Marshal Avatar asked Feb 03 '12 09:02

Marshal


1 Answers

Also, you can use VisibleChanged event in Form2

private Form2_VisibleChanged(object sender, EventArgs e)
{
    if (!this.Visible) { Refresh(); }
}

This might be more elegant...

like image 110
LolliPop Avatar answered Oct 26 '22 07:10

LolliPop