ich versuchen den tipp
http://www.vbarchiv.net/archiv/tipp_260.html
in vb.net umzuschreiben
im vb-code bei den fragezeichen kom ich nicht weiter
wenn noch was anderes nicht stimmt, nur sagen
binn über jede hilfe dankbar
lg armin
Private Sub PrintRow(ByVal xPos As Integer, ByVal yPos As Integer, ByVal fmt As _
String, ByVal sRow As String, ByVal sender As Object, ByVal e As _
System.Drawing.Printing.PrintPageEventArgs)
Dim OldScaleMode As Integer = e.Graphics.PageUnit
Dim sColWidth() As String
Dim sColText() As String
Dim i As Integer
Dim Font_Text As New Font("Arial", 10, FontStyle.Regular)
Dim Hoch As Double
Dim Schwarz As New Pen(Color.Black, 0.2)
Dim pd As New System.Drawing.Printing.PrintDocument
With e.Graphics
.PageUnit = GraphicsUnit.Millimeter 'legt Maseinheit fest
sColWidth = Split(fmt, "|")
sColText = Split(sRow, "|")
If UBound(sColText) < UBound(sColWidth) Then ReDim Preserve _
sColText(UBound(sColWidth))
' alle Spalten nacheinander drucken
For i = 0 To UBound(sColWidth)
pd.DefaultPageSettings.Margins.Left = xPos
.DrawString(PrintCheckLength(sColText(i), sColWidth(i), _
Font_Text, ???), Font_Text, Brushes.Black, xPos, yPos) _
'Was muß bei den ??? rein
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
'Printer.Print(PrintCheckLength(sColText(i), sColWidth(i),
' Font_Text))
If IsNumeric(VB.Left(sColWidth(i), 1)) Then
xPos = xPos + Val(sColWidth(i))
Else
xPos = xPos + Val(Mid$(sColWidth(i), 2))
End If
Next i
Printer.Print()
e.Graphics.PageUnit = OldScaleMode
End With
End Sub
' zum Drucken
' Länge prüfen und ggf. abschneiden
Private Function PrintCheckLength(ByVal sText As String, ByVal sWidth As _
String, ByVal TextFont As Font, _
ByVal e As System.Drawing.Printing.PrintPageEventArgs) As String
'Dim TextFont As New Font("Arial", 24, FontStyle.Bold)
Dim iLen As Integer
If VB.Left(sWidth, 1) = "^" Or VB.Left(sWidth, 1) = ">" Then
iLen = Val(Mid$(sWidth, 2))
Else
iLen = Val(sWidth)
End If
With e.Graphics
' wenn Text zu lang, Text am Ende kürzen
While .MeasureString(sText, TextFont).Width > iLen
sText = VB.Left(sText, Len(sText) - 1)
End While
If VB.Left(sWidth, 1) = "^" Then
' Text zentrieren
While .MeasureString(sText, TextFont).Width < iLen
sText = " " + sText + " "
End While
ElseIf VB.Left(sWidth, 1) = ">" Then
' Text rechtsbündig
While .MeasureString(sText, TextFont).Width < iLen
sText = " " + sText
End While
End If
End With
PrintCheckLength = RTrim$(sText)
End Function |