I set the first menu element to high 60 and textalign = MiddleCenter But the element simply ignores the property 
You need to place the text vertically and horizontally in the center
You can draw text in the middle of an element manually, in the Paint event.
private void openToolStripMenuItem_Paint(object sender, PaintEventArgs e) { var item = sender as ToolStripItem; TextRenderer.DrawText(e.Graphics, item.Text, item.Font, e.ClipRectangle, item.ForeColor //, TextFormatFlags.VerticalCenter | TextFormatFlags.HorizontalCenter ); } TextRenderer is rendering using GDI. By default, the formatting is set in the center, both vertically and horizontally. You can uncomment the line to set the formatting yourself.
You can use drawing with GDI +. Here, by default, drawing is performed in the upper left corner, so we set the right one.
private void openToolStripMenuItem_Paint(object sender, PaintEventArgs e) { var item = sender as ToolStripItem; var sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Center; e.Graphics.DrawString(item.Text, item.Font, Brushes.Black, e.ClipRectangle, sf); } In both cases, you must disable the display of the text element by default. To do this, you can set the DisplayStyle property to None .
Source: https://ru.stackoverflow.com/questions/894154/
All Articles