PrinterSettings.PrinterName プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > PrinterSettings.PrinterName プロパティの意味・解説 

PrinterSettings.PrinterName プロパティ

使用するプリンタの名前を取得または設定します

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

Dim instance As PrinterSettings
Dim value As String

value = instance.PrinterName

instance.PrinterName = value
public string PrinterName { get;
 set; }
/** @property */
public String get_PrinterName ()

/** @property */
public void set_PrinterName (String value)
public function get PrinterName
 () : String

public function set PrinterName
 (value : String)

プロパティ
使用するプリンタの名前。

解説解説
使用例使用例

PrinterName プロパティ設定して印刷プリンタ指定するコード例次に示しますIsValidtrue場合は、指定したプリンタドキュメント印刷されます。この例には、次の 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
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
PrinterSettings クラス
PrinterSettings メンバ
System.Drawing.Printing 名前空間
PrinterSettings.IsValid プロパティ
PrinterSettings.InstalledPrinters プロパティ
PrinterSettings.Duplex プロパティ
PrinterSettings.MaximumCopies プロパティ


このページでは「.NET Framework クラス ライブラリ リファレンス」からPrinterSettings.PrinterName プロパティを検索した結果を表示しています。
Weblioに収録されているすべての辞書からPrinterSettings.PrinterName プロパティを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からPrinterSettings.PrinterName プロパティ を検索

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

辞書ショートカット

すべての辞書の索引

「PrinterSettings.PrinterName プロパティ」の関連用語

PrinterSettings.PrinterName プロパティのお隣キーワード
検索ランキング

   

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



PrinterSettings.PrinterName プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2025 GRAS Group, Inc.RSS