Win Form never gets focus?!?

F

Fre

Hi all,

In my winform application, I want to check on certain moments if my
winform has focus. If so, some code will be executed. I noticed
however, that the winform never gets the focus, even when it clearly
has focus. How is that possible? What setting could I've messed with
that causes my winform never to get focus, even when activated?

void Form1_Activated(object sender, EventArgs e)
{
// always returns 'False' in my project (when I test
// in new project, it returns 'True' however!!)
Console.WriteLine("ACTIVATED & " + "this.Focused = " +
this.Focused);
}

Thanks in advance for your answers.

Frederik
 
R

Ravi Bhavnani

Try checking:

if (Form.ActiveForm.Equals (this))
...

instead of:

if (this.Focused)
...

/ravi
 

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