Meanie Posted February 25, 2003 Posted February 25, 2003 How can I go about updating a textbox when the focus on this textbox is lost? For instance, if the user clears the textbox, I want the default value to be entered when the user clicks away. Quote
*Experts* DiverDan Posted February 25, 2003 *Experts* Posted February 25, 2003 Try a MouseLeave event. Private Sub TextBox1_MouseLeave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.MouseLeave if TextBox1.Text = "" then TextBox1.Text = "Anything" end if End Sub This will leave Anything in the box if it is empty. I hope that helped. Dan Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Meanie Posted February 25, 2003 Author Posted February 25, 2003 Thanx for the help, but the code really doesn't do much if the mouse is moved before the textbox is made blank or if the user TABs between the controls instead of using the mouse. Quote
*Experts* DiverDan Posted February 25, 2003 *Experts* Posted February 25, 2003 (edited) You beat me to the reply, I was just going to update this replay to mention that. Sorry Private Sub TextBox1_Leave(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.Leave If TextBox1.Text = "" Then TextBox1.Text = "Anyhing" End If End Sub This will update the textbox if another is in focus. Edited February 25, 2003 by divil Quote Member, in good standing, of the elite fraternity of mentally challenged programmers. Dolphins Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.