Benutzer mit den meisten Antworten
Drucken über Vorschau

Frage
-
guten abend,
ich habe mal eine Druckvorschau programmiert(umfangreich) aber mein quellcode ist verlustig:-(
die Links online ond setup links in der spalte gehn nur mit IE
genau das gleiche will ich nei erstellen und hänge seit tage am anfang rum:(
Imports System.Drawing.Graphics Public Class Form1 Dim z As Graphics = CreateGraphics() Dim stift As New Pen(Color.Red, 2) ' PrintDocument-Objekt Dim WithEvents pDocument As New Printing.PrintDocument 'PrintPreviewDialog Dim WithEvents pDialog As New PrintPreviewDialog Private Sub Button1_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles Button1.Click pDialog.Document = pDocument ' Größe des Seitenvorschaufensters auf 800x600 festlegen pDialog.Width = 800 pDialog.Height = 600 pDialog.Top = 0 pDialog.Left = 0 z.DrawLine(stift, 100, 40, 100, 60) Zeichnen(z) ' Vorschau anzeigen pDialog.ShowDialog() End Sub Private Sub Zeichnen(ByVal z As Graphics) Dim Ft As New Font("Arial", 20) z.DrawRectangle(Pens.Blue, 110, 110, 115, 30) Dim s As String = Date.Now.ToString("HH:mm:ss") z.DrawString(s, Ft, Brushes.Red, 110, 110) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Zeichnen(z) z.DrawLine(stift, 100, 110, 100, 60) End Sub End Class
die vorschau zeigt eben nur weisses blatt, was muss ich da bei button1_cklick einfüegen?so dass:
z.DrawLine(stift, 100, 40, 100, 60)
Zeichnen(z)
pDialog.ShowDialog()
in der vorschau die linie angezeigt wird ?
danke gruss roland
rk
Antworten
-
Zeichnen mußt du im PrintPage Ereignis des Dokuments, etwa so ...
Private WithEvents pDocument As Printing.PrintDocument Private stift As New Pen(Color.Red, 2) Private Sub pDocument_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles pDocument.PrintPage Zeichnen(e.Graphics) e.Graphics.DrawLine(stift, 100, 110, 100, 60) End Sub Private Sub Zeichnen(ByVal z As Graphics) Dim Ft As New Font("Arial", 20) z.DrawRectangle(Pens.Blue, 110, 110, 115, 30) Dim s As String = Date.Now.ToString("HH:mm:ss") z.DrawString(s, Ft, Brushes.Red, 110, 110) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim pDialog As New PrintPreviewDialog pDocument = New Printing.PrintDocument pDialog.Width = 800 pDialog.Height = 600 pDialog.Top = 0 pDialog.Left = 0 pDialog.Document = pDocument pDialog.ShowDialog() End Sub
- Als Antwort vorgeschlagen Robert BreitenhoferModerator Mittwoch, 23. November 2011 08:56
- Als Antwort markiert Robert BreitenhoferModerator Freitag, 2. Dezember 2011 12:50
Alle Antworten
-
Zeichnen mußt du im PrintPage Ereignis des Dokuments, etwa so ...
Private WithEvents pDocument As Printing.PrintDocument Private stift As New Pen(Color.Red, 2) Private Sub pDocument_PrintPage(sender As Object, e As System.Drawing.Printing.PrintPageEventArgs) Handles pDocument.PrintPage Zeichnen(e.Graphics) e.Graphics.DrawLine(stift, 100, 110, 100, 60) End Sub Private Sub Zeichnen(ByVal z As Graphics) Dim Ft As New Font("Arial", 20) z.DrawRectangle(Pens.Blue, 110, 110, 115, 30) Dim s As String = Date.Now.ToString("HH:mm:ss") z.DrawString(s, Ft, Brushes.Red, 110, 110) End Sub Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click Dim pDialog As New PrintPreviewDialog pDocument = New Printing.PrintDocument pDialog.Width = 800 pDialog.Height = 600 pDialog.Top = 0 pDialog.Left = 0 pDialog.Document = pDocument pDialog.ShowDialog() End Sub
- Als Antwort vorgeschlagen Robert BreitenhoferModerator Mittwoch, 23. November 2011 08:56
- Als Antwort markiert Robert BreitenhoferModerator Freitag, 2. Dezember 2011 12:50