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?
views:
32answers:
2
+6
A:
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
Jason
2010-01-07 21:53:55
+1 I'm curious to know why? Is it because they want us to use Enter and Leave instead?
Coincoin
2010-01-07 22:02:25
+1
A:
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.
Hans Passant
2010-01-07 22:08:52