Reputation: 2292
I've got a menu that contains, among other things, some most-recently-used file paths. The paths to these files can be long, so the text sometimes gets clipped like "C:\Progra...\foo.txt"
I'd like to pop a tooltip with the full path when the user hovers over the item, but this doesn't seem possible with the Tooltip class in .NET 2.0.
Am I missing something obvious?
Upvotes: 19
Views: 26605
Reputation: 10986
On the MenusTrip set "ShowItemToolTips = True" and on the ToolStripMenuItem set your ToolTipText
yourMenuStrip.ShowItemToolTips = true;
yourToolStripMenuItem.ToolTipText = "some txt";
Upvotes: 3
Reputation: 123966
May be that I misunderstood you problem, but why do you need to use the Tooltip
class? You can assign your text to the ToolTipText property and it will be shown to the user.
Upvotes: 1
Reputation: 12489
If you are creating your menu items using the System.Windows.Forms.MenuItem class you won't have a "ToolTipText" property.
You should use the System.Windows.Forms.ToolStripMenuItem class which is new as of .Net Framework 2.0 and DOES include the "ToolTipText" property.
You also have to remember to specify ShowItemToolTips = True on the MenuStrip control
Upvotes: 28
Reputation: 11658
There is an article on CodeProject that implements a derived version of ToolStrip with custom tool tip support. This could be useful in situations where the default tool tip support is not flexible enough. http://www.codeproject.com/Tips/376643/ToolStrip-with-custom-ToolTip
Upvotes: 0
Reputation: 29138
Tooltip is set manually by:
testToolStripMenuItem2.ToolTipText = "My tooltip text";
The MenuItem can for example be part of this menu constellation: a menu strip with a menu item and a sub menu item. (This plumbing code is generated automatically for you in the code behind designer file if you use visual studio)
MenuStrip menuStrip1;
ToolStripMenuItem testToolStripMenuItem; // Menu item on menu bar
menuStrip1.Items.Add(testToolStripMenuItem);
ToolStripMenuItem testToolStripMenuItem2; // Sub menu item
testToolStripMenuItem.DropDownItems.Add(testToolStripMenuItem2)
Upvotes: 1
Reputation: 16758
Maybe you forgot to associate the tooltip with the control using SetToolTip.
Upvotes: -2