I want to make text appear in the text box but dissapear when the text box is clicked.
I want it to be like this: https://gyazo.com/17087686454b0b884104dcf08c551de0
That is basically all I want.
EDIT: OP has indicated this is a winforms
app
I want to make text appear in the text box but dissapear when the text box is clicked.
I want it to be like this: https://gyazo.com/17087686454b0b884104dcf08c551de0
That is basically all I want.
EDIT: OP has indicated this is a winforms
app
There is no direct method to add a placeholder to a text box. But you can do something like this easily.
Textbox newTextBox = new Textbox();
newTextBox.Text = "Search google or type URL";
newTextBox.GotFocus += GotFocus.EventHandle(RemoveText);
newTextBox.LostFocus += LostFocus.EventHandle(AddText);
public void RemoveText(object sender, EventArgs e)
{
if (newTextBox.Text == "Search google or type URL")
{
newTextBox.Text = "";
}
}
public void AddText(object sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(newTextBox.Text))
newTextBox.Text = "Search google or type URL";
}
Use placeholder attribute should do it