tags:

views:

1029

answers:

4

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?

A: 

Maybe you forgot to associate the tooltip with the control using SetToolTip.

John
+1  A: 

@Chris Karcher,

May be I misunderstood you problem, but why do you need to use Tooltip class? You can assign your text to ToolTipText property and it will be shown to user.

aku
I think it's the ToolTip property.
John
Control class doesn't have ToolTip property. It has ToolTipText
aku
Oops sorry I'm looking at a different MenuItem class.
John
+6  A: 

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.

Aydsman
This was an old application upgraded from .NET 1.1 and was using a MainMenu with MenuItems. I had never seen the MenuStrip class until now. Thanks!
Chris Karcher
A: 

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)
Andreas H.R. Nilsson