This code places the hint text at form load and manipulates it as follows:
C#
private void Form_load(object sender, EventArgs e)
{
textBox.Text = "Place Holder text...";
}
private void textBox_Enter(object sender, EventArgs e)
{
if(textBox.Text == "Place Holder text...")
{
textBox.Text = "";
}
}
private void textBox_Leave(object sender, EventArgs e)
{
if(textBox.Text.Trim() == "")
{
textBox.Text = "Place Holder text...";
}
}
VB.NET
Private Sub Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
textBox.Text = "Place Holder text..."
End Sub
Private Sub textBox_GotFocus(sender as Object,e as EventArgs) Handles textBox.GotFocus
if Trim(textBox.Text) = "Place Holder text..." Then
textBox.Text = ""
End If
End Sub
Private Sub textBox_LostFocus(sender as Object,e as EventArgs) Handles textBox.LostFocus
if Trim(textBox.Text) = "" Then
textBox.Text = "Place Holder text..."
End If
End Sub