I have tool tips running on a C# form and i have a checkbox to disable them showing up.
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
if (checkBox1.Checked)
{
Tool_Tips = false;
}
else
Tool_Tips = true;
}
where Tool_Tips
is a Global public bool.
each time I hover over a button I use the code:
private void Edge_Down_B_MouseHover(object sender, EventArgs e)
{
if (Tool_Tips)
{
Tool_Tip(Tool_Help.Edge_Down, Edge_Down_B);
}
}
my problem is that i have 4 buttons out of like 30 that will display a tooltip regardless of the boolean value. If i put a breakpoint in their code it works correctly, but if i remove the breakpoint their tooltip will show up when it shouldnt. I did clean build of release mode, rebuilt the project and tried debug mode and they continue to show a tooltip when they shouldnt.
I even changed the code of those 4 buttons to look like:
private void BlackandWhite_B_MouseHover(object sender, EventArgs e)
{
if (Tool_Tips)
{
if (!checkBox1.Checked)
开发者_运维知识库 Tool_Tip(Tool_Help.BlackWhite, BlackandWhite_B);
}
}
and they still show up in normal running mode. they won't show up if i place a breakpoint in.
Can anyone tell me why?
EDIT: if i run my program, it will start with tooltips disabled with the checkbox checked. I will uncheck the box and i will see tooltips. if i recheck the box to disable the tooltips, the tooltips i have viewed will still show up even though they are disabled.
first of all, make sure there aren't any other event handlers attached to those 4 buttons' Click.
after that try changing your method as:
private void checkBox1_CheckedChanged(object sender, EventArgs e)
{
Application.DoEvents();
Tool_Tips = !checkBox1.Checked;
}
the events might had gotten fired before the checkbox have been checked.
and if that did not work either, inside your Tool_Tip method write:
if (checkbox1.Checked) return;
and if none of those helped, shoot me in the head :D!
before shooting me, do this: in debug mode disable(or delete) all your breakpoints and put one just in your Tool_Tip method's first line.
make the bug show up and your breakpoint be hit. then from the debug menu, open Call Stack and check that from where your method has been called. this might lead you to the problem, because I think you method is being called from an unwanted point of code.
精彩评论