protected override void OnLayout (LayoutEventArgs e)
{
SetDisplayedItems ();
// Find the widest menu item
int widest = 0;
foreach (ToolStripItem tsi in this.DisplayedItems) {
if (!tsi.Available)
continue;
if (tsi.GetPreferredSize (Size.Empty).Width > widest)
widest = tsi.GetPreferredSize (Size.Empty).Width;
}
int x = this.Padding.Left;
widest += this.Padding.Horizontal;
int y = this.Padding.Top;
foreach (ToolStripItem tsi in this.DisplayedItems) {
if (!tsi.Available)
continue;
y += tsi.Margin.Top;
int height = 0;
if (tsi is ToolStripSeparator)
height = 7;
else
height = tsi.GetPreferredSize (Size.Empty).Height;
tsi.SetBounds (new Rectangle (x, y, widest, height));
y += tsi.Height + tsi.Margin.Bottom;
}
this.Size = new Size (widest + this.Padding.Horizontal, y + this.Padding.Bottom);// + 2);
}
/*