0

So I have tooltips on a variety of checkboxes and sliders in my application. This is partially necessary because the app is intended to be used by specific people at my company to create files (a large number of proprietary file formats, each with a variety of options). I decided at one point that tooltips were a good stopgap measure until there's a full set of documentation, plus it makes it easier on the fly to see what is out there.

I've considered using a global configuration checkbox that would enable or disable tooltips, but I was wondering if there was an elegant way to only display tooltips on mouseover while CTRL was being held down. I couldn't readily find anything on this. Any comments are appreciated.

Edit: The reason being that having tooltips pop up all the time as you move through the interface isn't really ideal, but being able to quickly access tooltips is very helpful.

Also, can someone please explain why this kind of question gets down-voted? It's frustrating to come here and see questions like "What is .NET" remain positive, and questions where I'm trying to learn something specific that isn't readily available on the Internet-at-large gets down-voted.

Here are all of the locations where the tooltip tipFRBx9P446 exists in my actual code.

Form1.Designer.cs:

        this.tipFRBx9P446 = new System.Windows.Forms.ToolTip(this.components);
        this.tipFRBx9P446.SetToolTip(this.cbFRBx9P446, "This will force P44 fields to reflect a value of \'6\'.  This can be used to ensure" + " proper testing of TFS WI 75062.");
        // 
        // tipFRBx9P446
        // 
        this.tipFRBx9P446.UseAnimation = false;
        this.tipFRBx9P446.UseFading = false;
        //
        private System.Windows.Forms.ToolTip tipFRBx9P446;

Form1.resx:

        <metadata name="tipFRBx9P446.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>762, 17</value>

1 Answer 1

1

You can use the Control.Modifier Key to check if CRTL is pressed:

if (Control.ModifierKeys == Keys.Control)
    {
       //CRTL is being pressed, show tooltip
    }

You should be able to use this code in your "Mouse_Hover"-event of the respective checkboxes. Hope this will help!

Sign up to request clarification or add additional context in comments.

6 Comments

That would definitely work, but I'm not creating the tooltips programatically, and VS doesn't insert anything in the code (that I can find) for the mouseOver event. It adds a property to the object that the tip is being added to. Or am I missing something?
Well, you have to add the tooltip somehow, i guess if you didnt write it directly in your code you added them in the designer view. You can, however, still access them in the code itself and display/hide them. You should probably read a little about the tooltip object to gain some background knowledge how it actually works. Good luck!
I added all code references to the main body above. I actually have read about the tooltip object. So, given the above, where would I add this? Since the code is a TrayLocation metadata reference, I cannot wrap that in an if-statement. So my question stands - and perhaps the answer is that unless I programmatically create the tooltips, I cannot do what I'm trying, which is fine.
It doesn't really matter if you create the tooltips programmatically or in the designer. You can, however, add the if statement in the hover event of the object you want to display the tooltip on. I would suggestive writing a method, if you want to use the code multiple times to reduce redundancy
I'll have to go that route. I think my point was that when you use the designer, there is no _hover or _mouseover added. The metadata is used to pop up the tooltip, and you can't wrap that with anything else. So it appears that the answer is: if done via designer, this isn't a possibility, if done programmatically, it's easy to do. :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.