Margins 클래스

정의

인쇄 페이지의 여백 크기를 지정합니다.

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

예제

이 예제에서는 System.Drawing, System.Drawing.PrintingSystem.IO 네임스페이스를 사용합니다.

다음 코드 예제에서는 문서의 기본 페이지 설정을 양쪽의 여백 1인치로 설정합니다.

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

설명

클래스는 MarginsPrintControllerPageSettings 여백 너비를 조작하는 데 사용됩니다. MarginsConverter 는 이 클래스의 형식 설명자입니다.

Left, Right, TopBottom 는 여백을 정의하는 속성입니다. Clone 는 동일한 Margins를 만듭니다. Equals 는 다른 개체의 차원이 와 같은지 여부를 결정합니다 Margins.

인쇄에 대한 자세한 내용은 네임스페이스 개요를 System.Drawing.Printing 참조하세요.

생성자

Margins()

1인치의 여백을 사용하여 Margins 클래스의 새 인스턴스를 초기화합니다.

Margins(Int32, Int32, Int32, Int32)

지정된 왼쪽, 오른쪽, 위쪽 및 아래쪽 여백을 사용하여 Margins 클래스의 새 인스턴스를 초기화합니다.

속성

Bottom

아래쪽 여백(1/100인치)을 가져오거나 설정합니다.

Left

왼쪽 여백 너비(1/100인치)를 가져오거나 설정합니다.

Right

오른쪽 여백 너비(1/100인치)를 가져오거나 설정합니다.

Top

위쪽 여백 너비(1/100인치)를 가져오거나 설정합니다.

메서드

Clone()

이 개체의 복제본을 멤버별로 검색합니다.

Equals(Object)

Margins를 지정된 Object와 비교하여 크기가 같은지 여부를 확인합니다.

GetHashCode()

왼쪽, 오른쪽, 위쪽 및 아래쪽 여백의 너비를 기준으로 해시 코드를 계신하고 검색합니다.

GetType()

현재 인스턴스의 Type을 가져옵니다.

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

현재 Object의 단순 복사본을 만듭니다.

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

Margins를 문자열로 변환합니다.

연산자

Equality(Margins, Margins)

Margins를 비교하여 크기가 같은지 여부를 확인합니다.

Inequality(Margins, Margins)

Margins를 비교하여 너비가 같지 않은지 여부를 확인합니다.

적용 대상

추가 정보