PrintDocument.DefaultPageSettings プロパティ
アセンブリ: System.Drawing (system.drawing.dll 内)

Public Property DefaultPageSettings As PageSettings
Dim instance As PrintDocument Dim value As PageSettings value = instance.DefaultPageSettings instance.DefaultPageSettings = value
public PageSettings DefaultPageSettings { get; set; }
public: property PageSettings^ DefaultPageSettings { PageSettings^ get (); void set (PageSettings^ value); }
/** @property */ public PageSettings get_DefaultPageSettings () /** @property */ public void set_DefaultPageSettings (PageSettings value)
public function get DefaultPageSettings () : PageSettings public function set DefaultPageSettings (value : PageSettings)
ドキュメントの既定のページ設定を指定する PageSettings。

DefaultPageSettings プロパティを使用して、複数の既定のページ設定を指定できます。たとえば、PageSettings.Color プロパティは、ページをカラー印刷するかどうかを指定します。PageSettings.Landscape プロパティは、横向きまたは縦向きの用紙方向を指定します。PageSettings.Margins プロパティは、ページの余白を指定します。
ページごとに設定を指定するには、PrintPage イベントまたは QueryPageSettings イベントを処理し、それぞれ PrintPageEventArgs または QueryPageSettingsEventArgs に含まれる PageSettings 引数を変更します。
![]() |
---|
印刷の開始後に DefaultPageSettings プロパティを使用してページ設定を変更しても、印刷中のページには影響を与えません。 |

ドキュメントの用紙方向を横向きに設定し、ドキュメントを印刷するコード例を次に示します。この例は、次の 3 つのことを前提にしています。変数 filePath が印刷するファイルのパスに設定されていること、PrintPage イベントを処理するメソッド pd_PrintPage が定義されていること、変数 printer がプリンタ名に設定されていることです。
この例では、System.Drawing、System.Drawing.Printing、および System.IO の各名前空間を使用します。
Public Sub Printing() Try streamToPrint = New StreamReader(filePath) Try printFont = New Font("Arial", 10) Dim pd As New PrintDocument() AddHandler pd.PrintPage, AddressOf pd_PrintPage pd.PrinterSettings.PrinterName = printer ' Set the page orientation to landscape. pd.DefaultPageSettings.Landscape = True pd.Print() Finally streamToPrint.Close() End Try Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub
public void Printing() { try { streamToPrint = new StreamReader (filePath); try { printFont = new Font("Arial", 10); PrintDocument pd = new PrintDocument(); pd.PrintPage += new PrintPageEventHandler(pd_PrintPage); pd.PrinterSettings.PrinterName = printer; // Set the page orientation to landscape. pd.DefaultPageSettings.Landscape = true; pd.Print(); } finally { streamToPrint.Close() ; } } catch(Exception ex) { MessageBox.Show(ex.Message); } }
public: void Printing() { 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 ); pd->PrinterSettings->PrinterName = printer; // Set the page orientation to landscape. pd->DefaultPageSettings->Landscape = true; pd->Print(); } finally { streamToPrint->Close(); } } catch ( Exception^ ex ) { MessageBox::Show( ex->Message ); } }
public void Printing() { try { streamToPrint = new StreamReader(filePath); try { printFont = new Font("Arial", 10); PrintDocument pd = new PrintDocument(); pd.add_PrintPage(new PrintPageEventHandler(pd_PrintPage)); pd.get_PrinterSettings().set_PrinterName(printer); // Set the page orientation to landscape. pd.get_DefaultPageSettings().set_Landscape(true); pd.Print(); } finally { streamToPrint.Close(); } } catch (System.Exception ex) { MessageBox.Show(ex.get_Message()); } } //Printing

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


Weblioに収録されているすべての辞書からPrintDocument.DefaultPageSettings プロパティを検索する場合は、下記のリンクをクリックしてください。

- PrintDocument.DefaultPageSettings プロパティのページへのリンク