Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TextBox_Leave Event Handler.

Status
Not open for further replies.

KoRUPT

Programmer
Jul 25, 2002
25
CA
I have a textbox control. In my Leave Event handler I check to see if it matches certain criteria and if it does not, I display a messagebox and TRY to set focus back to the textbox. This is not working for some reason. It displays the message box but does not do the other code withing the handler:

if(!isNumeric)
{
this.pageGeneral.Focus();
this.txtQuoteNumber.Focus();
this.txtQuoteNumber.Text = this.tempTextBox;
MessageBox.Show("Text must be Numeric Only (YYMMXX)");
}

The messagebox is called when it should be, but my textbox does not take the focus back as it should. Also, when I lose focus by pressing my OK button, I get the focus back to the textbox, but If i lose focus by clicking on a different page in my tab sheet, the page changes and I dont get the focus back. In both cases the text does not change to the this.tempTextBox variable like it should.

Is there similar functionality like the VB6 BeforeUpdate(Cancel as integer) where you can simply set Cancel to True and you will get the focus back + your old data? Any other suggestions?

Thank you.
 
nm. I guess System.ComponentModel.CancelEventArgs was to blatently obvious for me to notice.

PS: Is there a way to delete your posts?
 
There is a better way to do what you are trying to do. Use the Validate function. It will not let a user leave the textbox until it is correct filled in.

Check the help for more info.

Larsson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top