Windows Develop Bookmark and Share   
 index > Windows Forms General > How to find the control (TextBox) had focus when clicking the toolbar?
 

How to find the control (TextBox) had focus when clicking the toolbar?

I have a form with TextBox and ToolStrip. I'm handling the data upon leaving the control (through 'Leave' event handler).

When a button on the Toolbar clicked, the TextBox's Leave event is not triggerred.

How do I make sure the Leave event is triggered?

OR How can we find the last control had the focus?

R R Raja  Wednesday, January 16, 2008 4:11 PM

I've found the answer to my real issue.

The issue is, the ToolStrip buttons doesn't cause 'VALIDATION'.

Resolution:

By invoking 'this.Validate()' (this refers the form) from ToolStrip's clicked event forces the validation for all the controls. Thus the data can be handled upon 'OnValidating' event.

Thx. & Good luck everybody.

R R Raja  Thursday, January 17, 2008 9:39 AM

How do you know that the TextBox "had" the focus? Or do you really want "MouseLeave" instead of "Leave"?

Rudedog

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2667497&SiteID=1

Rudedog2  Wednesday, January 16, 2008 5:13 PM

Thx for your response.

I'm expecting the 'Leave' event.

Situation:

Form have several Text Boxes fordata entry. The data is validated and updated upon 'Leave'. After the data modification in any of the TextBox,pressing a button(say Save button)on the toolbar is not triggering the 'Leave' event handler.

R R Raja  Thursday, January 17, 2008 9:28 AM
It seems the event handler is not attached to the event.. And the better way to validate the entry is to write the code in the Validating event not in the Leave event.
Prasant Swain  Thursday, January 17, 2008 9:38 AM

I've found the answer to my real issue.

The issue is, the ToolStrip buttons doesn't cause 'VALIDATION'.

Resolution:

By invoking 'this.Validate()' (this refers the form) from ToolStrip's clicked event forces the validation for all the controls. Thus the data can be handled upon 'OnValidating' event.

Thx. & Good luck everybody.

R R Raja  Thursday, January 17, 2008 9:39 AM

You can use google to search for other answers

Custom Search

More Threads

• thread and Progress bar
• Combobox items Adding!!
• Clipboard on multiple controls
• To get the process Id from .exe name or to get the ProcessId while execution of batch file name
• How to draw mathematical shapes ?
• DirectShow/SAPI question
• checkedlistBox .net 2.0
• Label Mnemonic Custom Handling
• Object explorer issue in Management studio 2005 9.00.852
• How-to Start .Net executable with parameters?