private void AWBToolTip_Popup( object sender, PopupEventArgs e )
{
string text = this.GetToolTip( e.AssociatedControl );
string[] parts = text.Split( ' ' );
int maxWidth = 400;
SizeF sf;
using (Font f = new Font( e.AssociatedControl.Font, FontStyle.Bold ))
{
using (Graphics g = e.AssociatedControl.CreateGraphics())
{
int lineLength = (int)Math.Ceiling( g.MeasureString(text, f).Width) + 50;
foreach (string part in parts)
{
sf = g.MeasureString( part, f );
maxWidth = Math.Max( (int) Math.Ceiling( sf.Width ), maxWidth );
}
maxWidth = Math.Min( lineLength, maxWidth );
sf = g.MeasureString( text, f, maxWidth );
_calculatedHeight = (int) Math.Ceiling( sf.Height );
e.ToolTipSize = new Size(maxWidth + 2 * Padding, _calculatedHeight + 2 * Padding);
}
}
}