Nun lichtet sich das Bild langsam. Ich verstehe nur nachstehenden Code nicht. Wo muss ich das denn hinschreiben und was bedeutet er?
public Form1()
{
InitializeComponent();
printDocument1.PrintPage +=
new
PrintPageEventHandler(printDocument1_PrintPage);
}
Mein Code für die Seitenansicht sieht wie folgt aus. Wenn da mal jemand mal trüber schauen könnte, wäre nett.
Public Class Main
Dim MyDoc As New PrintDocument
Private idx As Integer
Private Sub SeitenansichtToolStripMenuItem_Click()
Ordnen()
idx = 0
AddHandler MyDoc.PrintPage, AddressOf MyDoc_PrintPage
Dim dlgSettings As New PrintPreviewDialog
dlgSettings.Document = MyDoc
Dim Result As DialogResult = dlgSettings.ShowDialog()
If Result = Windows.Forms.DialogResult.OK Then
MyDoc.Print()
End If
End Sub
Private Sub MyDoc_PrintPage()
On Error Resume Next
Dim ueberz As String()
Dim Zeilen As Integer
Dim Abstand_top As Integer
ueberz = ueber.ToString.Split("")
e.HasMorePages = True
Abstand_top = 60
Static intCurrentChar As Int32
Dim intPrintAreaHeight, intPrintAreaWidth, marginLeft, marginTop As Int32
With MyDoc.DefaultPageSettings
intPrintAreaHeight = .PaperSize.Height - .Margins.Top - .Margins.Bottom
intPrintAreaWidth = .PaperSize.Width - .Margins.Left - .Margins.Right
marginLeft = .Margins.Left ’ X-Koordinate
marginTop = .Margins.Top ’ Y-Koordinate
End With
If MyDoc.DefaultPageSettings.Landscape Then
Dim intTemp As Int32
intTemp = intPrintAreaHeight
intPrintAreaHeight = intPrintAreaWidth
intPrintAreaWidth = intTemp
End If
Dim intLineCount As Int32 = CInt(intPrintAreaHeight / Font.Height)
Dim rectPrintingArea As New RectangleF(marginLeft, marginTop + Abstand_top, intPrintAreaWidth, intPrintAreaHeight - Abstand_top)
Dim fmt As New StringFormat(StringFormatFlags.LineLimit)
Dim intLinesFilled, intCharsFitted As Int32
Dim new_font_ueber As Font = New Font(„Verdana“, 14, FontStyle.Bold)
Dim Uebera As StringFormat = New StringFormat()
Uebera.Alignment = StringAlignment.Center
Uebera.LineAlignment = StringAlignment.Center
Dim Ueberschrift As String = Tabelle.Rows(ueberz(idx)).Item(2).ToString
e.Graphics.DrawString(Ueberschrift, new_font_ueber, Brushes.Black, Me.PrintPreviewDialog.Width, e.PageSettings.Margins.Top + idx * e.PageSettings.PaperSize.Height, :Uebera)
e.Graphics.DrawLine(Pens.BlanchedAlmond, e.PageSettings.Margins.Left, e.PageSettings.Margins.Top + 15, Me.PrintPreviewDialog.Width * 2 - e.PageSettings.Margins.Right, e.PageSettings.Margins.Top + 15)
Dim Datu As StringFormat = New StringFormat()
Dim new_font_datu As Font = New Font(„Verdana“, 10)
Datu.Alignment = StringAlignment.Center
Datu.LineAlignment = StringAlignment.Center
Dim Datur As String
If Tabelle.Rows(ueberz(idx)).Item(1).ToString „“ And Tabelle.Rows(ueberz(idx)).Item(6).ToString „“ Then
Datur = Tabelle.Rows(ueberz(idx)).Item(1).ToString & " - " & Tabelle.Rows(ueberz(idx)).Item(6).ToString
Else
Datur = Tabelle.Rows(ueberz(idx)).Item(1).ToString & Tabelle.Rows(ueberz(idx)).Item(6).ToString
End If
e.Graphics.DrawString(Datur, new_font_datu, Brushes.Black, Me.PrintPreviewDialog.Width, e.PageSettings.Margins.Top + 40, Datu)
Dim Text As String
Dim rtf As New RichTextBox
rtf.Rtf = Tabelle.Rows(ueberz(idx)).Item(5).ToString
Text = rtf.Text 'Kommentar
e.Graphics.MeasureString(Mid(Text, intCurrentChar + 1), new_font_datu, New SizeF(intPrintAreaWidth, intPrintAreaHeight), fmt, intCharsFitted, intLinesFilled)
e.Graphics.DrawString(Mid(Text, intCurrentChar + 1), new_font_datu, Brushes.Black, rectPrintingArea, fmt)
intCurrentChar += intCharsFitted
If intCurrentChar