string s = "æµè¯ç¨";
private void Form2_Load(object sender, EventArgs e)
{
this.textBox1.Text = s;
this.textBox1.MouseClick += textBox1_MouseClick;
this.textBox1.Leave+=textBox1_Leave;
}
void textBox1_Leave(object sender,EventArgs e)
{
if (this.textBox1.Text.Trim() == "")
{
this.textBox1.Text =s;
}
}
void textBox1_MouseClick(object sender, MouseEventArgs e)
{
if(this.textBox1.Text.Trim()==s)
{
this.textBox1.Text = "";
}
}
å»ºè®®ç¨ textBox1.Enter += textBox1_Enter; è¿ä¸ªäºä»¶
温馨提示:答案为网友推荐,仅供参考