toasteroven
toasteroven

Reputation: 2790

Why are some events not shown in the Visual Studio properties window?

I wanted to add an event for a textbox to handle when it loses focus. I was sure I remembered some sort of LostFocus event, but I didn't see it in the Properties grid. But sure enough, the event exists if I access it programmatically. I'm using VS2008 - any reason why this event (and maybe others?) wasn't shown in the Properties grid?

Upvotes: 0

Views: 659

Answers (2)

Hans Passant
Hans Passant

Reputation: 941465

LostFocus is a troublesome event, this is the fine print from the SDK docs for WM_KILLFOCUS, the underlying Windows message:

While processing this message, do not make any function calls that display or activate a window. This causes the thread to yield control and can cause the application to stop responding to messages. For more information, see Message Deadlocks.

Use the Leave event instead.

Upvotes: 1

jason
jason

Reputation: 241641

Control.LostFocus is marked with [BrowsableAttribute(false)]. This means it will not be shown in the Properties window. For details see BrowsableAttribute.

Here's the declaration:

[BrowsableAttribute(false)]
public event EventHandler LostFocus

Upvotes: 6

Related Questions