Enter Event on Windows Forms do not always fire...

R

Rainer Queck

Hello NG,

the hint on the property editor for the Form "Enter" event sais: Gets fired,
if this control gets the active control.

In my application I experience, that this is "mostly" true, but some times
not.
I have a MDI application, and I use the <Form>.BringToFront() to activate a
hidden window. Usually I get the "Enter" event on doing this.
But I just had the case, that this event didn't get fired anymore. I
activated my Forms in the MDI several time, but no "Enter" event occured .
Stopping / Starting the Application brought the events back.

What is it I am doing wrong?
Are there "some" conditions by which "<Form>.BringToFront()" do not fire the
"Enter" event?

Thanks for help and hints.

Regards
Rainer Queck
 
N

Nicholas Paldino [.NET/C# MVP]

Rainer,

Are you sure that the code that you are calling doesn't throw an
exception? Events that are raised by the Control class (and derivatives) in
the System.Windows.Forms namespace swallow exceptions when they are thrown
in event handlers.

If you are not sure, try wrapping the code in a try/catch block and see
if any exceptions are thrown (write to a log file or something of that
nature if an exception is caught).
 
R

Rainer Queck

Hi Nicholas,

Nicholas Paldino said:
Rainer,

Are you sure that the code that you are calling doesn't throw an
exception?
No, my code throws no exception in the area we are talking about. I am
wrapping all my methods in try/catch and would know of exceptions.
Events that are raised by the Control class (and derivatives) in the
System.Windows.Forms namespace swallow exceptions when they are thrown in
event handlers.

If you are not sure, try wrapping the code in a try/catch block and see
if any exceptions are thrown (write to a log file or something of that
nature if an exception is caught).
Either I don't under stand you, or you don't understand me. My problem is
NOT that a exception is thrown or not thrown, my problem is, that the
"Enter" EVENT does not get fired some times.

Regards
Rainer
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rainer Queck said:
Hello NG,

the hint on the property editor for the Form "Enter" event sais: Gets
fired, if this control gets the active control.

In my application I experience, that this is "mostly" true, but some
times not.
I have a MDI application, and I use the <Form>.BringToFront() to activate
a hidden window. Usually I get the "Enter" event on doing this.
But I just had the case, that this event didn't get fired anymore. I
activated my Forms in the MDI several time, but no "Enter" event occured
.
Stopping / Starting the Application brought the events back.

What is it I am doing wrong?
Are there "some" conditions by which "<Form>.BringToFront()" do not fire
the "Enter" event?

Thanks for help and hints.

Regards
Rainer Queck
 
N

Nicholas Paldino [.NET/C# MVP]

Rainer,

I understand what you are saying. Just most people (erroneously) post a
question when an event doesn't fire, without realizing that windows forms
event handlers swallow exceptions, thinking that the event doesn't fire for
some other reason.

That being said, can you post a complete example which demonstrates the
problem?

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rainer Queck said:
Hi Nicholas,

Nicholas Paldino said:
Rainer,

Are you sure that the code that you are calling doesn't throw an
exception?
No, my code throws no exception in the area we are talking about. I am
wrapping all my methods in try/catch and would know of exceptions.
Events that are raised by the Control class (and derivatives) in the
System.Windows.Forms namespace swallow exceptions when they are thrown in
event handlers.

If you are not sure, try wrapping the code in a try/catch block and
see if any exceptions are thrown (write to a log file or something of
that nature if an exception is caught).
Either I don't under stand you, or you don't understand me. My problem is
NOT that a exception is thrown or not thrown, my problem is, that the
"Enter" EVENT does not get fired some times.

Regards
Rainer
--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Rainer Queck said:
Hello NG,

the hint on the property editor for the Form "Enter" event sais: Gets
fired, if this control gets the active control.

In my application I experience, that this is "mostly" true, but some
times not.
I have a MDI application, and I use the <Form>.BringToFront() to
activate a hidden window. Usually I get the "Enter" event on doing this.
But I just had the case, that this event didn't get fired anymore. I
activated my Forms in the MDI several time, but no "Enter" event occured
.
Stopping / Starting the Application brought the events back.

What is it I am doing wrong?
Are there "some" conditions by which "<Form>.BringToFront()" do not fire
the "Enter" event?

Thanks for help and hints.

Regards
Rainer Queck
 
R

Rainer Queck

Hello Nicholas,

Nicholas Paldino said:
Rainer,

I understand what you are saying. Just most people (erroneously) post
a question when an event doesn't fire, without realizing that windows
forms event handlers swallow exceptions, thinking that the event doesn't
fire for some other reason.

That being said, can you post a complete example which demonstrates the
problem?
Unfortunately not. I experienced this problem up to now only once my self.
Befor that, my customer complained about issues, which up to then I was not
able to reproduce, but the only possibillity for the bugs he was reporting
was, that the "Enter" event did not get fired. I was lucky to see that
problem at least once and now know that my assumption was right!

Is there any thing I can do to narrow the problem down?
The strange thing - to me - is, that once the issue occures, the "Enter"
event doesnt get fired at all any more no matter how often I call the
<form>.BringToFront().

Regards
Rainer
 

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