protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); var g = e.Graphics; if (adjustWidthToText) { Width = (int)g.MeasureString(Text, Font).Width + textPadding.Horizontal; adjustWidthToText = false; owner.UpdateButtons(); } var w = Width; var h = Height; // Draw borders. borderPen.Color = owner.uwfBorderColor; g.DrawLine(borderPen, 0, 0, w, 0); // Top. g.DrawLine(borderPen, 0, 0, 0, h - 1); // Left. g.DrawLine(borderPen, w - 1, 0, w - 1, h - 1); // Right. }