Hallo,
ich bekomme beim Ausdrucken mehrerer Tabpage Inhalte ab der 12.Tabpage diesen Fehler.
Drucke ich alles einzeln, funktioniert alles tadellos! Ich mach hier schon ewig rum. Vielleicht kann mich jemand in die richtige Richtung weisen
fehler.jpg
Vielen Dank schon mal im Voraus!
Anbei mein Code
ich bekomme beim Ausdrucken mehrerer Tabpage Inhalte ab der 12.Tabpage diesen Fehler.
Drucke ich alles einzeln, funktioniert alles tadellos! Ich mach hier schon ewig rum. Vielleicht kann mich jemand in die richtige Richtung weisen
fehler.jpg
Vielen Dank schon mal im Voraus!
Anbei mein Code
Code:
Private Sub AktuelleSeiteDruckenToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AktuelleSeiteDruckenToolStripMenuItem.Click Try Dim MyPrintPreview As New PrintPreviewDialog() Dim Myprintdialog As New PrintDialog() If Myprintdialog.ShowDialog = Windows.Forms.DialogResult.OK Then Myprintdialog.PrinterSettings = Myprintdialog.PrinterSettings Else Exit Sub End If Dim MyPrintDoc As New PrintDocument() MyPrintDoc.DocumentName = "Inspektionsliste Ausdruck" MyPrintDoc.PrinterSettings = Myprintdialog.PrinterSettings AddHandler MyPrintDoc.PrintPage, AddressOf Print_Page With PageSetupDialog1 .Document = MyPrintDoc .PageSettings = MyPrintDoc.DefaultPageSettings .PageSettings.Landscape = False .PageSettings.PrinterSettings = Myprintdialog.PrinterSettings End With If PageSetupDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then MyPrintDoc.DefaultPageSettings = PageSetupDialog1.PageSettings Else Exit Sub End If MyPrintDoc.DefaultPageSettings = PageSetupDialog1.PageSettings 'CWA 'MyPrintPreview.Document = MyPrintDoc 'MyPrintPreview.WindowState = FormWindowState.Maximized 'MyPrintPreview.ShowDialog() ' MyPrintDoc.Dispose() Dim g As PrintDocument = MyPrintDoc MyPrintDoc.Print() MyPrintDoc.Dispose() Catch ex As Exception MessageBox.Show(ex.ToString()) Stop End Try End Sub Dim page As Integer = 0 Private Sub Print_Page(ByVal sender As Object, ByVal MyPrintPageEvents As PrintPageEventArgs) TabControl1.SelectedIndex = page TabPage1.AutoScrollPosition = New Point(0, 0) Dim MyParentCntrl As Control = TabControl1.SelectedTab 'Get the parent control that the print buitton resides on TabControl1.SelectedTab = MyParentCntrl Dim bm As New Bitmap(MyParentCntrl.Parent.Bounds.Width, MyParentCntrl.Parent.Bounds.Height) bm = DrawAllSubControlsToBm(MyParentCntrl) 'size for image to scale to automaticaly Dim MyScaleFactor As Decimal = 1 MyScaleFactor = MyPrintPageEvents.MarginBounds.Height / bm.Height If bm.Width * MyScaleFactor > MyPrintPageEvents.MarginBounds.Width Then MyScaleFactor = MyPrintPageEvents.MarginBounds.Width / bm.Width End If Dim sourceRectangle As New Rectangle(0, 0, bm.Width, bm.Height) ' Position Gesamtausdruck! Dim destRetangle1 As New Rectangle(MyPrintPageEvents.MarginBounds.Left, MyPrintPageEvents.MarginBounds.Top, bm.Width * MyScaleFactor, bm.Height * MyScaleFactor) MyPrintPageEvents.Graphics.InterpolationMode = Drawing2D.InterpolationMode.Bicubic 'HighQualityBicubic MyPrintPageEvents.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias MyPrintPageEvents.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias MyPrintPageEvents.Graphics.DrawImage(bm, destRetangle1, sourceRectangle, GraphicsUnit.Pixel) If page < 14 Then MyPrintPageEvents.HasMorePages = True page += 1 End If If page = 14 Then MyPrintPageEvents.HasMorePages = False End If End Sub
Comment