PrinterSettings クラスとは? わかりやすく解説

PrinterSettings クラス

ドキュメント印刷方法に関する情報 (印刷使用するプリンタなど) を指定します

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

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

通常、PrintDocument.PrinterSettings プロパティまたは PageSettings.PrinterSettings プロパティ使用して PrinterSettingsアクセスし、プリンタ設定変更します。最も一般的なプリンタ設定は、印刷するプリンタ指定する PrinterName です。

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

使用例使用例

指定したプリンタ上でドキュメント印刷するコード例次に示します。この例には、次の 3 つの必要条件あります

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

Public Sub Printing(printer As
 String)
    Try
        streamToPrint = New StreamReader(filePath)
        Try
            printFont = New Font("Arial",
 10)
            Dim pd As New
 PrintDocument()
            AddHandler pd.PrintPage, AddressOf
 pd_PrintPage
            ' Specify the printer to use.
            pd.PrinterSettings.PrinterName = printer

            If pd.PrinterSettings.IsValid then
               pd.Print()
            Else
               MessageBox.Show("Printer is invalid.")
            End If
        Finally
            streamToPrint.Close()
        End Try
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub
   
public void Printing(string
 printer) {
  try {
    streamToPrint = new StreamReader (filePath);
    try {
      printFont = new Font("Arial", 10);
      PrintDocument pd = new PrintDocument(); 
      pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
      // Specify the printer to use.
      pd.PrinterSettings.PrinterName = printer;

      if (pd.PrinterSettings.IsValid) {
         pd.Print();
      } 
      else {    
         MessageBox.Show("Printer is invalid.");
      }
    } 
    finally {
      streamToPrint.Close();
    }
  } 
  catch(Exception ex) {
    MessageBox.Show(ex.Message);
  }
}

public:
   void Printing( String^ printer )
   {
      try
      {
         streamToPrint = gcnew StreamReader( filePath );
         try
         {
            printFont = gcnew System::Drawing::Font( "Arial",10 );
            PrintDocument^ pd = gcnew PrintDocument;
            pd->PrintPage += gcnew PrintPageEventHandler(
               this, &Form1::pd_PrintPage );
            // Specify the printer to use.
            pd->PrinterSettings->PrinterName = printer;
            if ( pd->PrinterSettings->IsValid )
            {
               pd->Print();
            }
            else
            {
               MessageBox::Show( "Printer is invalid." );
            }
         }
         finally
         {
            streamToPrint->Close();
         }
      }
      catch ( Exception^ ex ) 
      {
         MessageBox::Show( ex->Message );
      }
   }
public void Printing(String printer)
{
    try {
        streamToPrint = new StreamReader(filePath);
        try {
            printFont = new Font("Arial", 10);
            PrintDocument pd = new PrintDocument();
            pd.add_PrintPage(new PrintPageEventHandler(pd_PrintPage));

            // Specify the printer to use.
            pd.get_PrinterSettings().set_PrinterName(printer);
            if (pd.get_PrinterSettings().get_IsValid()) {
                pd.Print();
            }
            else {
                MessageBox.Show("Printer is invalid.");
            }
        }
        finally {
            streamToPrint.Close();
        }
    }
    catch (System.Exception ex) {
        MessageBox.Show(ex.get_Message());
    }
} //Printing
継承階層継承階層
System.Object
  System.Drawing.Printing.PrinterSettings
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PrinterSettings メンバ
System.Drawing.Printing 名前空間
PrinterName
PrintDocument.PrinterSettings プロパティ
PageSettings.PrinterSettings プロパティ



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

辞書ショートカット

すべての辞書の索引

「PrinterSettings クラス」の関連用語

PrinterSettings クラスのお隣キーワード
検索ランキング

   

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



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

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

©2025 GRAS Group, Inc.RSS