I am attempting to give a winforms Textbox control placeholder text by programmatically setting the respective control's text during the GetFocus and LostFocus events. However, for whatever reason the control never reflects the updated text.
This is what I'm attempting:
Private Sub TextBoxEmail_GotFocus(ByVal sender As Object, ByVal e As EventArgs) Handles TextBoxEmail.GotFocus
Dim this As TextBox = DirectCast(sender, TextBox)
With this
If .Text = "Email Address" Then
.ForeColor = Bootstrap.Utilities.Color.TextBody
.Text = String.Empty
End If
End With
End Sub
Private Sub TextBoxEmail_LostFocus(ByVal sender As Object, ByVal e As EventArgs) Handles TextBoxEmail.LostFocus
Dim this As TextBox = DirectCast(sender, TextBox)
With this
.ForeColor = Bootstrap.Utilities.Color.TextLight
If String.IsNullOrWhiteSpace(.Text) Then
.Text = "Email Address"
End If
End With
End Sub
What is odd is that if I setup a breakpoint in the LostFocus event handler and step through the code using the F11 shortcut, it is constantly cycles through the GotFocus and LostFocus events.