Freigeben über


Margins.Bottom-Eigenschaft

Ruft den unteren Rand in 1/100 Zoll ab oder legt diesen fest.

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

Syntax

'Declaration
Public Property Bottom As Integer
'Usage
Dim instance As Margins
Dim value As Integer

value = instance.Bottom

instance.Bottom = value
public int Bottom { get; set; }
public:
property int Bottom {
    int get ();
    void set (int value);
}
/** @property */
public int get_Bottom ()

/** @property */
public void set_Bottom (int value)
public function get Bottom () : int

public function set Bottom (value : int)

Eigenschaftenwert

Der untere Seitenrand in 1/100 Zoll.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

Die Bottom-Eigenschaft wird auf einen Wert kleiner als 0 (null) festgelegt.

Hinweise

Wenn Sie die Ränder in Millimetern messen, multiplizieren Sie die gewünschte Randbreite in Millimetern mit 3,937, um die richtige Angabe für 1/100 Zoll zu bestimmen. Wenn der Rand beispielsweise eine Breite von 25 mm haben soll, multiplizieren Sie diesen Wert mit 3,937, und das abgerundete Ergebnis entspricht 98. Sie legen den entsprechenden Margins-Member demnach auf 98 fest.

Beispiel

Verwenden Sie für dieses Beispiel die Namespaces System.Drawing, System.Drawing.Printing und System.IO.

Im folgenden Codebeispiel werden die Standardseiteneinstellungen für ein Dokument auf eine Breite von 1 Zoll für den linken und rechten Seitenrand und auf eine Breite von 1,5 Zoll für den oberen und unteren Seitenrand festgelegt.

Public Sub 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)
            Dim pd As New PrintDocument()
            ' This assumes that a method, named pd_PrintPage, has been
            ' defined. pd_PrintPage handles the PrintPage event. 
            AddHandler pd.PrintPage, AddressOf 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()
        End Try
    Catch ex As Exception
        MessageBox.Show("An error occurred printing the file - " & ex.Message)
    End Try
End Sub    
   
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);
  }
}
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 = gcnew StreamReader( filePath );
      try
      {
         printFont = gcnew System::Drawing::Font( "Arial",10 );
         PrintDocument^ pd = gcnew PrintDocument;
         
         /* This assumes that a method, named pd_PrintPage, has been
                   defined. pd_PrintPage handles the PrintPage event. */
         pd->PrintPage += gcnew PrintPageEventHandler( this, &Sample::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( String::Concat( "An error occurred printing the file - ", ex->Message ) );
   }

}
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.add_PrintPage(new PrintPageEventHandler(pd_PrintPage));

            /* This assumes that a variable of type string, named 
               printer, has been set to the printer's name.
             */
            pd.get_PrinterSettings().set_PrinterName(printer);

            // Set the left and right margins to 1 inch.
            pd.get_DefaultPageSettings().get_Margins().set_Left(100);
            pd.get_DefaultPageSettings().get_Margins().set_Right(100);

            // Set the top and bottom margins to 1.5 inches.
            pd.get_DefaultPageSettings().get_Margins().set_Top(150);
            pd.get_DefaultPageSettings().get_Margins().set_Bottom(150);
            pd.Print();
        }
        finally {
            streamToPrint.Close();
        }
    }
    catch (System.Exception ex) {
        MessageBox.Show(("An error occurred printing the file - " 
            + ex.get_Message()));
    }
} //Printing

Plattformen

Windows 98, Windows 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

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Margins-Klasse
Margins-Member
System.Drawing.Printing-Namespace
Left
Right
Top