Printen in vb.net

Status
Niet open voor verdere reacties.

kabourterplop

Gebruiker
Lid geworden
25 feb 2007
Berichten
323
Goedendag,

Ik ben bezig met een programma, maar nu wil ik alle resultaten die gevonden zijn met termen uitlaten printen, dat lukt allemaal maar nu het volgende tussen het merk type - prijs (het zijn zo 6 velden) zitten tabs om alles mooi in kolommen te laten lopen. Maar nu wilt hij geen vbTab / controlschar.Tab afdrukken.

Weet iemand hoe het dan wel moet?

Hier is de class waarmee ik print:

Code:
Public Class myPrinter
    ' Inherits all the functionality of a PrintDocument
    Inherits Printing.PrintDocument
    ' Private variables to hold default font and text
    Private fntPrintFont As Font
    Private strText As String
    Public Sub New(ByVal Text As String)
        ' Sets the file stream
        MyBase.New()
        strText = Text
    End Sub
    Public Property Text() As String
        Get
            Return strText
        End Get
        Set(ByVal Value As String)
            strText = Value
        End Set
    End Property
    Protected Overrides Sub OnBeginPrint(ByVal ev _
    As Printing.PrintEventArgs)
        ' Run base code
        MyBase.OnBeginPrint(ev)
        ' Sets the default font
        If fntPrintFont Is Nothing Then
            fntPrintFont = New Font("Tahoma", 8)
        End If
    End Sub
    Public Property Font() As Font
        ' Allows the user to override the default font
        Get
            Return fntPrintFont
        End Get
        Set(ByVal Value As Font)
            fntPrintFont = Value
        End Set
    End Property
    Protected Overrides Sub OnPrintPage(ByVal ev _
    As Printing.PrintPageEventArgs)
        ' Provides the print logic for our document
        ' Run base code
        MyBase.OnPrintPage(ev)
        ' Variables
        Static intCurrentChar As Integer
        Dim intPrintAreaHeight, intPrintAreaWidth, _
        intMarginLeft, intMarginTop As Integer
        ' Set printing area boundaries and margin coordinates
        With MyBase.DefaultPageSettings
            intPrintAreaHeight = .PaperSize.Height - _
            .Margins.Top - .Margins.Bottom
            intPrintAreaWidth = .PaperSize.Width - _
            .Margins.Left - .Margins.Right
            intMarginLeft = .Margins.Left 'X
            intMarginTop = .Margins.Top 'Y
        End With
        ' If Landscape set, swap printing height/width
        If MyBase.DefaultPageSettings.Landscape Then
            Dim intTemp As Integer
            intTemp = intPrintAreaHeight
            intPrintAreaHeight = intPrintAreaWidth
            intPrintAreaWidth = intTemp
        End If
        ' Calculate total number of lines
        Dim intLineCount As Int32 = _
        CInt(intPrintAreaHeight / Font.Height)
        ' Initialise rectangle printing area
        Dim rectPrintingArea As New RectangleF(intMarginLeft, _
        intMarginTop, intPrintAreaWidth, intPrintAreaHeight)
        ' Initialise StringFormat class, for text layout
        Dim objSF As New StringFormat(StringFormatFlags.LineLimit)
        ' Figure out how many lines will fit into rectangle
        Dim intLinesFilled, intCharsFitted As Int32
        ev.Graphics.MeasureString(Mid(strText, _
        UpgradeZeros(intCurrentChar)), Font, _
        New SizeF(intPrintAreaWidth, _
        intPrintAreaHeight), objSF, _
        intCharsFitted, intLinesFilled)
        ' Print the text to the page
        ev.Graphics.DrawString(Mid(strText, UpgradeZeros(intCurrentChar)), Font, Brushes.Black, rectPrintingArea, objSF)
        ' Increase current char count
        intCurrentChar += intCharsFitted
        ' Check whether we need to print more
        If intCurrentChar < strText.Length Then
            ev.HasMorePages = True
        Else
            ev.HasMorePages = False
            intCurrentChar = 0
        End If
    End Sub
    Public Function UpgradeZeros(ByVal Input As Integer) As Integer
        ' Upgrades all zeros to ones
        ' - used as opposed to defunct IIF or messy If statements
        If Input = 0 Then
            Return 1
        Else
            Return Input
        End If
    End Function
End Class
 
pfff...

Kon die klas niet lanfer ofso?
Je kunt ook in een regel een textbox afdrukken
 
Weet ik,

Maar het zijn 92 resultaten en die passen niet op een A4-tje, deze class print dus meerdere A4-tjes maar dus niet de tabs.

Het is helemaal niet zo lang die class.
 
Weet iemand wat hoe ik dit kan oplossen, ik ben al tijden aan het zoeken maar kan geen oplossing vinden.
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan