现在,这是我使用的程序进入/离开:如何在其他地方点击时离开文本框?
private void tbFullName_Enter(object sender, EventArgs e)
{
if (tbFullName.Text == "Full name")
{
tbFullName.Text = "";
tbFullName.ForeColor = Color.Black;
}
}
private void tbFullName_Leave(object sender, EventArgs e)
{
if (tbFullName.Text == "")
{
tbFullName.Text = "Full name";
tbFullName.ForeColor = SystemColors.InactiveCaption;
}
}
当我集中在另一元件上,只留下。当我点击背景或其他任何地方时,我希望它离开。我怎样才能做到这一点?
顺便说一句,这只是我使用的水印的一个例子。可能还有其他情况。 – Qedized
该功能内置于Windows。研究提示横幅 – Plutonix
你应该通过控制焦点来做到这一点,比如当点击背景时将ContainerControl.ActiveControl属性设置为当前表单。 – saeed