我正在尝试在鼠标悬停期间在禁用的文本框上显示工具提示.我知道因为控件被禁用,所以以下内容不起作用:
I am trying to get a tooltip to display on a disabled textbox during a mouse over. I know because the control is disabled the following won't work:
private void textBox5_MouseHover(object sender, EventArgs e)
{
// My tooltip display code here
}
如何在鼠标悬停在禁用控件上时显示工具提示?
How can I get the tooltip to display on a mouse over of a disabled control?
非常感谢
如果禁用控制,MouseHover 不会触发.相反,您可以检查 Form MouseMove 事件是否悬停文本框
MouseHover wont fire if control is disabled. Instead you can check in Form MouseMove event whether you hover the textbox
public Form1()
{
InitializeComponent();
textBox1.Enabled = false;
toolTip.InitialDelay = 0;
}
private ToolTip toolTip = new ToolTip();
private bool isShown = false;
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if(textBox1 == this.GetChildAtPoint(e.Location))
{
if(!isShown)
{
toolTip.Show("MyToolTip", this, e.Location);
isShown = true;
}
}
else
{
toolTip.Hide(textBox1);
isShown = false;
}
}
这篇关于C# 在禁用的文本框(表单)上显示工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!