Where is teh LostFocus event in the property window of textbox

D

dbuchanan

On the help page "TextBox Members" clearly there is an event for LostFocus.
It is inherited from control.

So without the event directly available for TextBox how do I use it?

I know I could create the event in code, but isn't there a more direct way?
 
L

Linda Liu [MSFT]

Hi,

Based on my understanding, you want to hook up the LostFocus event of a
TextBox in a direct way. If I'm off base, please feel free to let me know.

For some reason, the LostFocus event of the TextBox class is not available
in the Properties window's Events tab. This design time behavior should be
by design.

So there's no direct way to hook up the LostFocus event of the TextBox. We
need to do this by code. Nevertheless, the IntelliSense feature in VS IDE
makes it easy and convenient to hook up an event by code.

Alternatively, you may use the Leave event of the TextBox class , which is
available in the Properties window.

Hope this helps.

If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

dbuchanan

Leave and LostFocus are different events.I have since found this information
in help comparing Leave and LostFocus:

Leave Occurs when the input focus leaves the control.(inherited from
Control)
LostFocus Occurs when the control loses focus.(inherited from Control)

The oprder of events under different circumstances:

When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on),
by calling the Select or SelectNextControl methods, or by setting the
ContainerControl.ActiveControl property to the current form, focus events
occur in the following order:

.. Enter
.. GotFocus
.. Leave
.. Validating
.. Validated
.. LostFocus

When you change the focus by using the mouse or by calling the Focus method,
focus events occur in the following order:

.. Enter
.. GotFocus
.. LostFocus
.. Leave
.. Validating
.. Validated

Note:
The GotFocus and LostFocus events are low-level focus events that are tied
to the WM_KILLFOCUS and WM_SETFOCUS Windows messages. Typically, the
GotFocus and LostFocus events are only used when updating UICues or when
writing custom controls. Instead the Enter and Leave events should be used
for all controls except the Form class, which uses the Activated and
Deactivate events. For more information about the GotFocus and LostFocus
events, see the WM_SETFOCUS and WM_KILLFOCUS topics in the "Keyboard Input
Reference" section of the Platform SDK Documentation in the MSDN library at
http://msdn.microsoft.com/library.

So I guess I should not use 'LostFocus' and instead use 'Leave'.
 
L

Linda Liu [MSFT]

Hi Dbuchanan,

Thank you for your prompt reply.

No matter which event you'd like to use, it is convenient for you to
subscribe an event either in the Properties window or in code.

As for subscribing an event in code, type += operator after an event field
and IntelliSense prompts you with the option to press the TAB key. This
inserts a new instance of a delegate that points to the method handling the
event.

If you press TAB, IntelliSense automatically completes the statement for
you and displays the event handler reference as selected text in the Code
Editor. To complete the automatic event hookup, IntelliSense prompts you to
press the TAB key again, to create an empty stub for the event handler.

If you have any concern, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support
 

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