PrinterSettings クラス
アセンブリ: System.Drawing (system.drawing.dll 内)


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

指定したプリンタ上でドキュメントを印刷するコード例を次に示します。この例には、次の 3 つの必要条件があります。
この例では、System.Drawing、System.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.Drawing.Printing.PrinterSettings


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


PrinterSettings コンストラクタ
アセンブリ: System.Drawing (system.drawing.dll 内)


既定のコンストラクタは、すべてのフィールドを既定値に初期化します。
通常、PrinterSettings のインスタンスは作成しません。PrintDocument.PrinterSettings を使用して、プリンタに対する設定を指定します。

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


PrinterSettings プロパティ

名前 | 説明 | |
---|---|---|
![]() | IsDefaultPrinter | ユーザーが明示的に PrinterName を設定した場合を除き、PrinterName プロパティが、通常使うプリンタに指定されているかどうかを示す値を取得します。 |
![]() | IsPlotter | プリンタがプロッタかどうかを示す値を取得します。 |
![]() | IsValid | PrinterName プロパティが有効なプリンタに指定されているかどうかを示す値を取得します。 |
![]() | LandscapeAngle | 縦向きの用紙を回転して横向きにする場合の角度 (°) を取得します。 |
![]() | MaximumCopies | プリンタで一度に印刷できる最大部数を取得します。 |
![]() | MaximumPage | PrintDialog で選択できる FromPage または ToPage の最大値を取得または設定します。 |
![]() | MinimumPage | PrintDialog で選択できる FromPage または ToPage の最小値を取得または設定します。 |
![]() | PaperSizes | プリンタでサポートされている用紙サイズを取得します。 |
![]() | PaperSources | プリンタで使用できる用紙トレイを取得します。 |
![]() | PrinterName | 使用するプリンタの名前を取得または設定します。 |
![]() | PrinterResolutions | プリンタでサポートされている解像度をすべて取得します。 |
![]() | PrintFileName | ファイルに出力する際にファイル名を取得または設定します。 |
![]() | PrintRange | ユーザーが指定した印刷ページの番号を取得または設定します。 |
![]() | PrintToFile | ポートではなく、ファイルに印刷出力を送信するかどうかを示す値を取得または設定します。 |
![]() | SupportsColor | プリンタがカラー印刷をサポートしているかどうかを示す値を取得します。 |
![]() | ToPage | 印刷終了ページの番号を取得または設定します。 |

PrinterSettings メソッド

名前 | 説明 | |
---|---|---|
![]() | Clone | この PrinterSettings のコピーを作成します。 |
![]() | CreateMeasurementGraphics | オーバーロードされます。 プリンタ情報を格納する Graphics を返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetHdevmode | オーバーロードされます。 プリンタ設定に対応する DEVMODE 構造体を識別するハンドルを作成します。 |
![]() | GetHdevnames | プリンタ設定に対応する DEVNAMES 構造体を識別するハンドルを作成します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | IsDirectPrintingSupported | オーバーロードされます。 イメージ ファイルの印刷をプリンタがサポートしているかどうかを示す値を返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | SetHdevmode | 特定のハンドルから PrinterSettings に関連情報をコピーします。 |
![]() | SetHdevnames | 特定のハンドルから PrinterSettings に関連情報をコピーします。 |
![]() | ToString | オーバーライドされます。 PrinterSettings に関する情報を文字列形式で提供します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

PrinterSettings メンバ
ドキュメントの印刷方法に関する情報 (印刷に使用するプリンタなど) を指定します。
PrinterSettings データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | IsDefaultPrinter | ユーザーが明示的に PrinterName を設定した場合を除き、PrinterName プロパティが、通常使うプリンタに指定されているかどうかを示す値を取得します。 |
![]() | IsPlotter | プリンタがプロッタかどうかを示す値を取得します。 |
![]() | IsValid | PrinterName プロパティが有効なプリンタに指定されているかどうかを示す値を取得します。 |
![]() | LandscapeAngle | 縦向きの用紙を回転して横向きにする場合の角度 (°) を取得します。 |
![]() | MaximumCopies | プリンタで一度に印刷できる最大部数を取得します。 |
![]() | MaximumPage | PrintDialog で選択できる FromPage または ToPage の最大値を取得または設定します。 |
![]() | MinimumPage | PrintDialog で選択できる FromPage または ToPage の最小値を取得または設定します。 |
![]() | PaperSizes | プリンタでサポートされている用紙サイズを取得します。 |
![]() | PaperSources | プリンタで使用できる用紙トレイを取得します。 |
![]() | PrinterName | 使用するプリンタの名前を取得または設定します。 |
![]() | PrinterResolutions | プリンタでサポートされている解像度をすべて取得します。 |
![]() | PrintFileName | ファイルに出力する際にファイル名を取得または設定します。 |
![]() | PrintRange | ユーザーが指定した印刷ページの番号を取得または設定します。 |
![]() | PrintToFile | ポートではなく、ファイルに印刷出力を送信するかどうかを示す値を取得または設定します。 |
![]() | SupportsColor | プリンタがカラー印刷をサポートしているかどうかを示す値を取得します。 |
![]() | ToPage | 印刷終了ページの番号を取得または設定します。 |

名前 | 説明 | |
---|---|---|
![]() | Clone | この PrinterSettings のコピーを作成します。 |
![]() | CreateMeasurementGraphics | オーバーロードされます。 プリンタ情報を格納する Graphics を返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetHdevmode | オーバーロードされます。 プリンタ設定に対応する DEVMODE 構造体を識別するハンドルを作成します。 |
![]() | GetHdevnames | プリンタ設定に対応する DEVNAMES 構造体を識別するハンドルを作成します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | IsDirectPrintingSupported | オーバーロードされます。 イメージ ファイルの印刷をプリンタがサポートしているかどうかを示す値を返します。 |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | SetHdevmode | 特定のハンドルから PrinterSettings に関連情報をコピーします。 |
![]() | SetHdevnames | 特定のハンドルから PrinterSettings に関連情報をコピーします。 |
![]() | ToString | オーバーライドされます。 PrinterSettings に関する情報を文字列形式で提供します。 |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- PrinterSettingsのページへのリンク