[C#] 纯文本查看 复制代码 public String WaterText { get; set; }
private void textBox1_Enter(object sender, EventArgs e)
{
if (textBox1.Text == WaterText || textBox1.Text == "")
{
textBox1.Text = "";
textBox1.ForeColor = Color.Black;
}
}
private void Form1_Load(object sender, EventArgs e)
{
WaterText = "要设置的水印文字";
textBox1.Text = WaterText;
textBox1.ForeColor = Color.Gray;
}
private void textBox1_Leave(object sender, EventArgs e)
{
if (textBox1.Text == "" || textBox1.Text == WaterText)
{
textBox1.Text = WaterText;
textBox1.ForeColor = Color.Gray;
}
} |