Jamrelian Jamrelian - 11 months ago 57
C# Question

ToolStripMenuItem bigger vertical padding, or vertically centering text in a bigger ToolStripMenuItem

I'm trying to set a bigger vertical padding for ToolStripMenuItems in a ContextMenuStrip. However, changing the Padding.Top property adds padding to the bottom, instead of the top.

I also tried setting a larger Height for the ToolStripMenuItem, it works, however, the text always gets aligned on top, even if the TextAlign property is MiddleCenter. It should be vertical aligned to the center!

I've tried different settings for different properties, nothing works. The idea is that I cannot get the ToolStripMenuItem to have more space around its text, both to the top and to the bottom.

I'm using C#, Windows Forms, Net 2.0, Visual Studio 2010 Express, Windows 7.

Answer Source

You can get the same effect using Margin instead of Padding which will keep the Text of the ToolStripMenuItem aligned.

The drawback is that this wont modify the size of the highlight rectangle when the item is selected so it can look a little strange if you increase a lot the height.