110,534
社区成员
发帖
与我相关
我的任务
分享
//设置默认值
textBox1.ForeColor = Color.LightGray;
textBox1.Text = "用户名或邮件地址";
//点击时光标默认在最前面
private void textBox1_Click(object sender, EventArgs e)
{
textBox1.SelectionStart = 0;
}
private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Right)
return;
if (textBox1.Text == "用户名或邮件地址")
{
textBox1.Text = "";
textBox1.ForeColor = Color.Black;
}
}