这是条不归路

呜呜呜~

导航

C# TextBox 控件添加提示


 

//Lostfocus当一个控件失去焦点时触发,定义控件失去焦点时的方法
this.textBox1.LostFocus += new System.EventHandler(this.textBox1_LostFocus);
//GotFocus是在一个对象得到焦点时发生,定义控件得到焦点时的方法
 this.textBox1.GotFocus += new System.EventHandler(this.textBox1_GotFocus);
 1 private void txtHospitalSearch_GotFocus(object sender, EventArgs e)
 2         {
 3             txt.Text = "";
 4             txt.ForeColor = Color.Black;
 5         }
 6         private void txtHospitalSearch_LostFocus(object sender, EventArgs e)
 7         {
 8             txt.Text = "我是提示哦";
 9             txt.ForeColor = Color.Gray;
10         }

 

posted on 2023-06-08 18:55  En'  阅读(160)  评论(0编辑  收藏  举报