Export (0) Print
Expand All

Margins.Bottom Property

Gets or sets the bottom margin, in hundredths of an inch.

Namespace: System.Drawing.Printing
Assembly: System.Drawing (in system.drawing.dll)

public int Bottom { get; set; }
/** @property */
public int get_Bottom ()

/** @property */
public void set_Bottom (int value)

public function get Bottom () : int

public function set Bottom (value : int)

Not applicable.

Property Value

The bottom margin, in hundredths of an inch.

Exception typeCondition

ArgumentException

The Bottom property is set to a value that is less than 0.

If you measure margins in millimeters, multiply the margin width you want in millimeters by 3.937 to determine the correct measurement in hundredths of an inch. For example, if you want a margin of 25mm, multiply by 3.937 and the result is 98 when rounded down. You would then set the appropriate Margins member to 98.

Use the System.Drawing, System.Drawing.Printing, and System.IO namespaces for this example.

The following code example sets the default page settings for a document to left and right margins of 1 inch in width, and top and bottom margins of 1.5 inches in width.

public void Printing()
{
  try 
  {
    /* This assumes that a variable of type string, named filePath,
       has been set to the path of the file to print. */
    streamToPrint = new StreamReader (filePath);
    try 
    {
      printFont = new Font("Arial", 10);
      PrintDocument pd = new PrintDocument(); 
      /* This assumes that a method, named pd_PrintPage, has been
         defined. pd_PrintPage handles the PrintPage event. */
      pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
      /* This assumes that a variable of type string, named 
         printer, has been set to the printer's name. */
      pd.PrinterSettings.PrinterName = printer;

      // Set the left and right margins to 1 inch.
      pd.DefaultPageSettings.Margins.Left = 100;
      pd.DefaultPageSettings.Margins.Right = 100;
      // Set the top and bottom margins to 1.5 inches.
      pd.DefaultPageSettings.Margins.Top = 150;
      pd.DefaultPageSettings.Margins.Bottom = 150;

      pd.Print();
    } 
    finally 
    {
      streamToPrint.Close() ;
    }
  } 
  catch(Exception ex) 
  { 
    MessageBox.Show("An error occurred printing the file - " + ex.Message);
  }
}


Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft