Showing a tooltip for a MenuItem

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)

On the MenusTrip set "ShowItemToolTips = True" and on the ToolStripMenuItem set your ToolTipText

yourMenuStrip.ShowItemToolTips = true;
yourToolStripMenuItem.ToolTipText = "some txt";

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


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.

Tags:

.Net

Winforms