グループボックスにいくつかのコントロールがあり、プリンタに送信したいのですが。グループボックスの内容をプリンタに送信する方法
このコードでは、グループボックスからbmpファイルを作成しています。どうすればボタンクリックでプリンタに送ることができますか?
Private Sub Doc_PrintPage(sender As Object, e As PrintPageEventArgs)
Dim x As Single = e.MarginBounds.Left
Dim y As Single = e.MarginBounds.Top
Dim bmp As New Bitmap(Me.GroupBox1.Width, Me.GroupBox1.Height)
Me.GroupBox1.DrawToBitmap(bmp, New Rectangle(0, 0, Me.GroupBox1.Width, Me.GroupBox1.Height))
e.Graphics.DrawImage(DirectCast(bmp, Image), x, y)
End Sub
私は、ボタンのクリックイベントであります、
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
BMP = New Bitmap(GroupBox1.Width, GroupBox1.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb)
GroupBox1.DrawToBitmap(BMP, New Rectangle(0, 0, GroupBox1.Width, GroupBox1.Height))
Dim pd As New PrintDocument
Dim pdialog As New PrintDialog
AddHandler pd.PrintPage, (Sub(s, args)
args.Graphics.DrawImage(BMP, 0, 0)
args.HasMorePages = False
End Sub)
pdialog.ShowDialog()
pd.PrinterSettings.PrinterName = pdialog.PrinterSettings.PrinterName
pd.Print()
End Sub
私の目を開いた。有用なリンク。問題の領域に掲載された最終作業コード。 –