I wanted to create a textbox which has a help label inside the box which then disappears when the box has characters entered into it. I found one way of doing it which involves loading the form with text inside the textbox in the colour grey and then removing it when the user clicks on the box... The problem with this is i wanted to use a string.IsNullOrEmpty(textboxIP)
but when the user hasn't typed anything into the box, the program sees the box as not empty as it has the pre-loaded writing in it. This is the code I used to remove the text on user click...
Dim WatermarkIP As String = "Yes"
Dim WatermarkPing As String = "Yes"
Private Sub textboxIP_Enter(sender As Object, e As EventArgs) Handles textboxIP.Enter
If WatermarkIP = "Yes" Then
textboxIP.Clear()
textboxIP.ForeColor = Color.Black
WatermarkIP = "No"
End If
End Sub
Private Sub textboxPing_Enter(sender As Object, e As EventArgs) Handles textboxPing.Enter
If WatermarkPing = "Yes" Then
textboxPing.Clear()
textboxPing.ForeColor = Color.Black
WatermarkPing = "No"
End If
End Sub
Does anyone know of a better way of creating a greyed out help/hint label inside the textbox which IS NOT counted as text inside the box, does not have to be deleted by the user before they can type in the box and is maybe a bit simpler?