Saravanan
Saravanan

Reputation: 11602

how to handle the Windows Form got focus event in C#?

I have Windows Form.Now i want to perform some function when the form get focused(that was already opened).For example,form has already opened, and user minimized that window and perform some other function.Finally, he will maximize that form to doing function.So, on that time, i want to perform function(while getting focused to the user). how i do it?

Upvotes: 0

Views: 10972

Answers (1)

Bala R
Bala R

Reputation: 109017

You can try the Form's Activated event.

EDIT:

This is the code I tried

public Form1()
{
    this.Activated += new EventHandler(Form1_Activated);
}

void Form1_Activated(object sender, EventArgs e)
{
    Console.WriteLine("Activated");
}

Upvotes: 7

Related Questions