Margins 클래스

정의

인쇄 페이지의 여백 크기를 지정합니다.Specifies the dimensions of the margins of a printed page.

public ref class Margins : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.Printing.MarginsConverter))]
[System.Serializable]
[System.ComponentModel.TypeConverter("System.Drawing.Printing.MarginsConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
public class Margins : ICloneable
type Margins = class
    interface ICloneable
Public Class Margins
Implements ICloneable
상속
Margins
특성
구현

예제

이 예에서는 System.Drawing, System.Drawing.PrintingSystem.IO 네임 스페이스를 사용 합니다.Use the System.Drawing, System.Drawing.Printing, and System.IO namespaces for this example.

다음 코드 예제에서는 기본 페이지 설정을 설정 문서에 대 한 1 인치의 여백을 양쪽에서.The following code example sets the default page settings for a document to margins of 1 inch on each side.

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;
         
         // Create a new instance of Margins with one inch margins.
         Margins^ margins = gcnew Margins( 100,100,100,100 );
         pd->DefaultPageSettings->Margins = margins;
         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.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;
      // Create a new instance of Margins with one inch margins.
      Margins margins = new Margins(100,100,100,100);
      pd.DefaultPageSettings.Margins = margins;
      pd.Print();
    } 
    finally 
    {
      streamToPrint.Close() ;
    }
  } 
  catch(Exception ex) 
  { 
    MessageBox.Show("An error occurred printing the file - " + ex.Message);
  }
}

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
            ' Create a new instance of Margins with one inch margins.
            Dim margins As New Margins(100, 100, 100, 100)
            pd.DefaultPageSettings.Margins = margins
            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
   

설명

Margins 클래스는 PageSettingsPrintController에서 여백의 너비를 조작 하는 데 사용 됩니다.The Margins class is used to manipulate the width of margins in PageSettings and PrintController. MarginsConverter는이 클래스에 대 한 형식 설명자입니다.MarginsConverter is the type descriptor for this class.

Left, Right, TopBottom은 여백을 정의 하는 속성입니다.Left, Right, Top, and Bottom are properties that define the margins. Clone는 동일한 Margins를 만듭니다.Clone creates an identical Margins. Equals는 다른 개체의 차원이 Margins와 동일한 지 여부를 확인 합니다.Equals determines if another object has the same dimensions as a Margins.

인쇄에 대 한 자세한 내용은 System.Drawing.Printing 네임 스페이스 개요를 참조 하세요.For more information about printing, see the System.Drawing.Printing namespace overview.

생성자

Margins()

1인치의 여백을 사용하여 Margins 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the Margins class with 1-inch wide margins.

Margins(Int32, Int32, Int32, Int32)

지정된 왼쪽, 오른쪽, 위쪽 및 아래쪽 여백을 사용하여 Margins 클래스의 새 인스턴스를 초기화합니다.Initializes a new instance of the Margins class with the specified left, right, top, and bottom margins.

속성

Bottom

아래쪽 여백 100 인치 단위로 가져오거나 설정 합니다.Gets or sets the bottom margin, in hundredths of an inch.

Left

왼쪽 여백 너비(1/100인치)를 가져오거나 설정합니다.Gets or sets the left margin width, in hundredths of an inch.

Right

오른쪽 여백 너비(1/100인치)를 가져오거나 설정합니다.Gets or sets the right margin width, in hundredths of an inch.

Top

100 인치 단위로 위쪽 여백 너비를 가져오거나 설정 합니다.Gets or sets the top margin width, in hundredths of an inch.

메서드

Clone()

이 개체에서 멤버의 중복을 검색합니다.Retrieves a duplicate of this object, member by member.

Equals(Object)

Margins를 지정된 Object와 비교하여 크기가 같은지 여부를 확인합니다.Compares this Margins to the specified Object to determine whether they have the same dimensions.

GetHashCode()

왼쪽, 오른쪽, 위쪽 및 아래쪽 여백의 너비를 기준으로 해시 코드를 계신하고 검색합니다.Calculates and retrieves a hash code based on the width of the left, right, top, and bottom margins.

GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
ToString()

Margins를 문자열로 변환합니다.Converts the Margins to a string.

연산자

Equality(Margins, Margins)

Margins를 비교하여 크기가 같은지 여부를 확인합니다.Compares two Margins to determine if they have the same dimensions.

Inequality(Margins, Margins)

Margins를 비교하여 너비가 같지 않은지 여부를 확인합니다.Compares two Margins to determine whether they are of unequal width.

적용 대상

추가 정보