using System; using System.Collections.Generic; using System.Drawing.Printing; using System.Text; using System.Drawing; using System.Windows.Forms; namespace VanWassenhove.WinForms { #region ResizedControlPrintPageEventHandler /// /// This class allows the user to print a control. /// This class tries to maximize the control so that no scrollbars are shown. /// See The source of the event. /// A PrintPageEventArgs that contains the event data. public override void PrintPage(object sender, PrintPageEventArgs e) { if (this.IsFirstPage) { Control control = this.Control; Size oldSize = control.Size; control.Height = Math.Max(control.Height, control.PreferredSize.Height); control.Width = Math.Max(control.Width, control.PreferredSize.Width); base.PrintPage(sender, e); control.Size = oldSize; } else { base.PrintPage(sender, e); } } #endregion } #endregion }