只有当我在文本框中写东西时,工具提示才会出现



这是我为C#窗体中的按钮编写的代码。我希望每当我悬停时都能显示工具提示,但它只有在我在文本框中插入一些文本后才能工作

这是代码

private void passwordTextBox_TextChanged(object sender, EventArgs e)
{
ToolTip toolTip3 = new ToolTip();
toolTip3.AutoPopDelay = 5000;
toolTip3.InitialDelay = 1000;
toolTip3.ReshowDelay = 500;
toolTip3.ShowAlways = true;
toolTip3.SetToolTip(this.passwordTextBox, "Not more than 50 characters, no special charachters!");
}

您设置了错误事件的工具提示。最好的方法是在表单加载事件上设置工具提示。

private void Form1_Load(object sender, EventArgs e)
{
this.setToolTip();
}
private void setToolTip()
{
ToolTip toolTip3 = new ToolTip();
toolTip3.AutoPopDelay = 5000;
toolTip3.InitialDelay = 1000;
toolTip3.ReshowDelay = 500;
toolTip3.ShowAlways = true;
toolTip3.SetToolTip(this.passwordTextBox, "Not more than 50 characters, no special charachters!");
//Tooltip for other controls
}

如果你还面临任何问题,请告诉我。

最新更新