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

コンピュータにインストールされているすべてのプリンタの名前を表す PrinterSettings.StringCollection。



インストールされているプリンタを comboInstalledPrinters コンボ ボックスに表示し、選択内容が変更されたときに、PrinterName プロパティを使用して印刷を行うプリンタを設定するコード例を次に示します。フォームが初期化されると、PopulateInstalledPrintersCombo ルーチンが呼び出されます。この例では、printDoc という名前の PrintDocument 変数と、特定のコンボ ボックスが存在することが必要です。
Private Sub PopulateInstalledPrintersCombo() ' Add list of installed printers found to the combo box. ' The pkInstalledPrinters string will be used to provide the display string. Dim i as Integer Dim pkInstalledPrinters As String For i = 0 to PrinterSettings.InstalledPrinters.Count - 1 pkInstalledPrinters = PrinterSettings.InstalledPrinters.Item(i) comboInstalledPrinters.Items.Add(pkInstalledPrinters) Next End Sub Private Sub comboInstalledPrinters_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles comboInstalledPrinters.SelectedIndexChanged ' Set the printer to a printer in the combo box when the selection changes. If comboInstalledPrinters.SelectedIndex <> -1 Then ' The combo box's Text property returns the selected item's text, which is the printer name. printDoc.PrinterSettings.PrinterName = comboInstalledPrinters.Text End If End Sub
private void PopulateInstalledPrintersCombo() { // Add list of installed printers found to the combo box. // The pkInstalledPrinters string will be used to provide the display string. String pkInstalledPrinters; for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++){ pkInstalledPrinters = PrinterSettings.InstalledPrinters[i]; comboInstalledPrinters.Items.Add(pkInstalledPrinters); } } private void comboInstalledPrinters_SelectionChanged(object sender, System.EventArgs e) { // Set the printer to a printer in the combo box when the selection changes. if (comboInstalledPrinters.SelectedIndex != -1) { // The combo box's Text property returns the selected item's text, which is the printer name. printDoc.PrinterSettings.PrinterName= comboInstalledPrinters.Text; } }
private: void PopulateInstalledPrintersCombo() { // Add list of installed printers found to the combo box. // The pkInstalledPrinters String will be used to provide the display String. String^ pkInstalledPrinters; for ( int i = 0; i < PrinterSettings::InstalledPrinters->Count; i++ ) { pkInstalledPrinters = PrinterSettings::InstalledPrinters[ i ]; comboInstalledPrinters->Items->Add( pkInstalledPrinters ); } } void comboInstalledPrinters_SelectionChanged( Object^ sender, System::EventArgs^ e ) { // Set the printer to a printer in the combo box when the selection changes. if ( comboInstalledPrinters->SelectedIndex != -1 ) { // The combo box's Text property returns the selected item's text, which is the printer name. printDoc->PrinterSettings->PrinterName = comboInstalledPrinters->Text; } }
private void PopulateInstalledPrintersCombo() { // Add list of installed printers found to the combo box. // The pkInstalledPrinters string will be used to provide the // display string. String pkInstalledPrinters; for (int i = 0; i < PrinterSettings.get_InstalledPrinters(). get_Count(); i++) { pkInstalledPrinters = PrinterSettings.get_InstalledPrinters(). get_Item(i); comboInstalledPrinters.get_Items().Add(pkInstalledPrinters); } } //PopulateInstalledPrintersCombo private void comboInstalledPrinters_SelectionChanged(Object sender, System.EventArgs e) { // Set the printer to a printer in the combo box when the // selection changes. if (comboInstalledPrinters.get_SelectedIndex() != -1) { // The combo box's Text property returns the selected item's // text, which is the printer name. printDoc.get_PrinterSettings(). set_PrinterName(comboInstalledPrinters.get_Text()); } } //comboInstalledPrinters_SelectionChanged


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に収録されているすべての辞書からPrinterSettings.InstalledPrinters プロパティを検索する場合は、下記のリンクをクリックしてください。

- PrinterSettings.InstalledPrinters プロパティのページへのリンク