views:

158

answers:

2

I have a check box that is disabled that should be showing a tooltip when hovered over, but instead nothing happens. Once the checkbox is clicked on the tooltip shows momentarily then flashes on and off very fast. What could be causing this? The tooltip should also be showing for every control involved, but shows for some and not others eventhough the tooltip is explicitly set for all controls. What could be causing this behavior?

Here is the event handler:

this.MouseHover += new EventHandler(OrderSummaryDetails_MouseHover);


void EventHandler_MouseHover(object sender, EventArgs e)
{
     if (someCondition)
     {
         this.mFormTips.Show("Please open order form to manually modify this order", this);
     }
}
+1  A: 

I can't be positive, but if using WinForms, and you have your checkbox disabled (as in not enabled), then the checkbox will not receive events. This will cause tooltips not to show up properly.

I had the exact same problem before with a image button and what I ended up having to do was to create a gray scale of the image and swap it out when I wanted the button to be "disabled". I had to add the tooltip to the button and the image (two separate UI elements) and swap out the UI elements.

Joseph
Beat me to it...this is what I was gonna say. :)
Yoopergeek
I see what youre saying, but the tooltip is showing up, but just for a moment. So it does seem to be receiving events.
DJ
@DJ It might be responding to some kind of click event. It's hard to say, because when you disable controls the event handling for that particular control stops.
Joseph
@Joseph Well I have the debugger setup to break on the event and it is breaking for the controls, but I am not seeing the tip.
DJ
@DJ on which controls and for which events?
Joseph
@Joseph All of the controls. It shows fine on the form, but when I mouseover a control the breakpoint is hit, but I see nothing.
DJ
@DJ Ok, then can you show some code as to how you're actually creating the tooltip?
Joseph
@Joseph I added the event handler. Its pretty basic stuff.
DJ
A: 

I added a MouseMove event and applied it to all the controls.

void OrderSummaryDetails_MouseMove(object sender, MouseEventArgs e)
{
      Control control = GetChildAtPoint(e.Location);
      if (control != null)
      {
          string toolTipString = mFormTips.GetToolTip(control);
          this.mFormTips.ShowAlways = true;
          // trigger the tooltip with no delay and some basic positioning just to give you an idea
          mFormTips.Show(toolTipString, control, control.Width / 2, control.Height / 2);
      }
}
DJ