C# Winform 文本框默认提示信息
2021-05-19 02:28
标签:rgs gray oid box nta winform 信息 for csharp C# Winform 文本框默认提示信息 标签:rgs gray oid box nta winform 信息 for csharp 原文地址:https://www.cnblogs.com/baissy/p/11724042.htmlprivate 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 = "";
}
}
文章标题:C# Winform 文本框默认提示信息
文章链接:http://soscw.com/index.php/essay/87463.html