Search code examples
winformsmenustripownerdrawn

Change size of ToolStripMenuItem


I'm custom drawing a menu item in a MenuStrip. The problem I'm having is that the menu item insists on sizing itself based on the text, which is not what I want (there is no text). I can set AutoSize to false and explicitly specify a size, but the containing menu (ToolStripDropDown) still sizes itself based on the text, which causes it to be too small to contain the entire menu item.

Is there a straightforward way to set the size of a menu item?


Solution

  • This comments in an article on CodeProject explains the nature of my issue:

    While you can handle the Paint event for a ToolStripMenuItem, ToolStripMenuItem isn't intended to be "owner drawn". If you want to handle the drawing of a particular tool strip item, the recommended means is to create your own ToolStripItem-derived type. See ToolStripItem Class[^] for an example.