C#.net WinForms how to causes text in textbox to disappear when textbox is on focus?

Something like the code below. Please note, this is not a compiled code. Just sharing the idea, plus you may like to retain the default settings if user did not enter any text.

For that handle a lost focus and reset to default.

Something like the code below. Please note, this is not a compiled code. Just sharing the idea, plus you may like to retain the default settings if user did not enter any text.

For that handle a lost focus and reset to default. Public class FancyTextBox : TextBox{ private bool _isDefaultText; public FancyTextBox(){ UpdateDefaultSettings(true); } protected override void OnGotFocus(EventArgs e) { base. OnGotFocus(e); UpdateDefaultSettings(false); } protected override void OnLostFocus(EventArgs e) { base.

OnLostFocus(e); if (String. IsNullOrEmpty(Text)) { //Retain Default Setting. UpdateDefaultSettings(true); } } private void UpdateDefaultSettings(bool isDefault){ _isDefaultText = isDefault; if(_isDefaultText){ Text = "Please enter"; this.

ForeColor= Color. Gray; } else{ Text = ""; ForeColor = Color. Black; } } }.

Thanks for the response! :) – BlueMonster Dec 4 at 3:52.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions