在對路徑進行驗證的時候用到了tooltip 控件,如果使用SetToolTip方法的話只有在鼠標在textbox上面時才會出現。
如果希望tip一直顯示,知道非法字符全部去掉才消失的話就要使用show方法。
但是使用Show方法會出現控件氣泡的箭頭方向第一次出現時會指向下方:
正確的應該是這樣的:
解決方法就是:
if (textBox1.Text.Contains(
"
w
"))
{
toolTip1.Active = false;
toolTip1.SetToolTip(textBox1, " test ");
toolTip1.Active = true;
toolTip1.Show( " test ", textBox1, textBox1.Width / 2, textBox1.Height / 2); // 提示內容,控件,tip顯示X偏移,tip顯示Y偏移
}
else
{
toolTip1.Active = false;
toolTip1.Hide(textBox1);
}
{
toolTip1.Active = false;
toolTip1.SetToolTip(textBox1, " test ");
toolTip1.Active = true;
toolTip1.Show( " test ", textBox1, textBox1.Width / 2, textBox1.Height / 2); // 提示內容,控件,tip顯示X偏移,tip顯示Y偏移
}
else
{
toolTip1.Active = false;
toolTip1.Hide(textBox1);
}
使用show的話只能用hide方法隱藏