Marginsとは? わかりやすく解説

Margins クラス

印刷ページ余白大きさ指定します

名前空間: System.Drawing.Printing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

<SerializableAttribute> _
Public Class Margins
    Implements ICloneable
[SerializableAttribute] 
public class Margins : ICloneable
[SerializableAttribute] 
public ref class Margins : ICloneable
/** @attribute SerializableAttribute() */ 
public class Margins implements ICloneable
SerializableAttribute 
public class Margins implements ICloneable
解説解説

Margins クラスは、PageSettings と PrintController で余白の幅を操作するために使用されます。MarginsConverter は、このクラスの型記述子です。

LeftRightTop、および Bottom は、余白定義するプロパティです。Clone は、Margins複製作成しますEquals は、別のオブジェクト大きさMargins と同じであるどうかを判断します

印刷詳細については、System.Drawing.Printing 名前空間概要トピック参照してください

使用例使用例

この例では、System.DrawingSystem.Drawing.Printing、および System.IO の各名前空間使用します

ドキュメント既定ページ設定として、左右余白1 インチ設定するコード例次に示します

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
   
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);
  }
}

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.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);

            // Create a new instance of Margins with one inch margins.
      
            Margins margins = new Margins(100, 100, 100, 100);
            pd.get_DefaultPageSettings().set_Margins(margins);
            pd.Print();
        }
        finally {
            streamToPrint.Close();
        }
    }
    catch (System.Exception ex) {
        MessageBox.Show(("An error occurred printing the file - " 
            + ex.get_Message()));
    }
} //Printing
継承階層継承階層
System.Object
  System.Drawing.Printing.Margins
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Margins メンバ
System.Drawing.Printing 名前空間
PageSettings
PrintController
MarginsConverter
その他の技術情報
Windows フォームにおける印刷サポート

Margins コンストラクタ ()


Margins コンストラクタ

Margins クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

参照参照

関連項目

Margins クラス
Margins メンバ
System.Drawing.Printing 名前空間

Margins コンストラクタ (Int32, Int32, Int32, Int32)

Margins クラス新しインスタンス指定した上下左右余白初期化します。

名前空間: System.Drawing.Printing
アセンブリ: System.Drawing (system.drawing.dll 内)
構文構文

例外例外
例外種類条件

ArgumentException

left パラメータの値が 0 未満です。

または

right パラメータの値が 0 未満です。

または

top パラメータの値が 0 未満です。

または

bottom パラメータの値が 0 未満です。

使用例使用例

この例では、System.Drawing、System.Drawing.Printing、および System.IO の各名前空間使用します

ドキュメント既定ページ設定として、左右余白1 インチ幅に設定するコード例次に示します

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
   
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);
  }
}

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.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);

            // Create a new instance of Margins with one inch margins.
      
            Margins margins = new Margins(100, 100, 100, 100);
            pd.get_DefaultPageSettings().set_Margins(margins);
            pd.Print();
        }
        finally {
            streamToPrint.Close();
        }
    }
    catch (System.Exception ex) {
        MessageBox.Show(("An error occurred printing the file - " 
            + ex.get_Message()));
    }
} //Printing
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
Margins クラス
Margins メンバ
System.Drawing.Printing 名前空間

Margins プロパティ


パブリック プロパティパブリック プロパティ

参照参照

関連項目

Margins クラス
System.Drawing.Printing 名前空間
PageSettings
PrintController
MarginsConverter

その他の技術情報

Windows フォームにおける印刷サポート

Margins メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Margins クラス
System.Drawing.Printing 名前空間
PageSettings
PrintController
MarginsConverter

その他の技術情報

Windows フォームにおける印刷サポート

Margins メンバ

印刷ページ余白大きさ指定します

Margins データ型公開されるメンバを以下の表に示します


パブリック コンストラクタパブリック コンストラクタ
パブリック プロパティパブリック プロパティ
パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Margins クラス
System.Drawing.Printing 名前空間
PageSettings
PrintController
MarginsConverter

その他の技術情報

Windows フォームにおける印刷サポート



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「Margins」の関連用語

Marginsのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Marginsのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS