C# Winform 文本框默认提示信息


private string Notes = "提示文本";
private void textBox1_Leave(object sender, EventArgs e)
{
    //  退出失去焦点,重新显示
    if (string.IsNullOrEmpty(textBox1.Text))
    {
        textBox1.ForeColor = Color.DarkGray;
        this.textBox1.Text = Notes;
    }
}

private void textBox1_Enter(object sender, EventArgs e)
{
    //  进入获得焦点,清空
    if (textBox1.Text == Notes)
    {
        textBox1.ForeColor = Color.Black;
        this.textBox1.Text = "";
    }
}

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM