| Dim PrinterName As String プリンター名がセットされています。 順番にプリンタ名がコンボボックスにADDされているのですが コンボボックスの中は、ADDされている感じは、ありますが文字が全く見えません。 System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count は、プリンターに表示されている通り5個です。
■No84089 (魔界の仮面弁士 さん) に返信 > 2017/05/15(Mon) 07:41:12 編集(投稿者) > > ■No84088 (YKT さん) に返信 >>コンボボックスにプリンタ名が追加れないことで悩んでいます。 > まず、元のコードにおいて > Dim PrinterName As String > には何がセットされているのでしょうか? > > そして System.Drawing.Printing.PrinterSettings.InstalledPrinters.Count は > どのような値を返してきますか? これが 0 を返すなら、そもそも > 利用可能なプリンターが存在していない可能性が出てきます。 > > >>Me.cboSize.Items.Clear() >>Me.cboWise.Items.Clear() > > この 2 つは特に使われていないようですが、今回の質問とは無関係なのでしょうか。 > (size は "サイズ" のことだとして…、wise は "賢明な" ?) > > >>Dim prtPrinter As New System.Drawing.Printing.PrintDocument > 既定のプリンターを得たいだけなら、PrintDocument を経由せずとも > PrinterSettings だけで辿れますよ。 > > 'Imports System.Drawing.Printing > > Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load > Dim printerNames = PrinterSettings.InstalledPrinters.OfType(Of String)().ToArray() > 'Array.Sort(printerNames) > cboPrinter.DataSource = printerNames > cboPrinter.SelectedIndex = Array.IndexOf(printerNames, New PrinterSettings().PrinterName) > End Sub |