Showing a tooltip for a MenuItem

前端 未结 6 1826
北恋
北恋 2021-01-17 11:25

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:\\

6条回答
  •  渐次进展
    2021-01-17 12:01

    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)
    

提交回复
热议问题