views:

26

answers:

1

I have been working on some code that prints a textbox that lists contact information. When I try to print it, it doesn't print out the tabs that I used to format the text. Here is my code:

Private Sub PrintPage(ByVal sender As Object, ByVal ev As PrintPageEventArgs) _
Handles prndoc.PrintPage

    Dim fnt As Font = resultTextBox.Font
    ev.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias

    Dim area As SizeF = New SizeF(ev.MarginBounds.Width, ev.MarginBounds.Height)
    Dim lines, chars As Integer
    ev.Graphics.MeasureString(resultTextBox.Text.Substring(mStringPos), fnt, _
                              area, StringFormat.GenericTypographic, chars, _
                              lines)

    Dim rc As New RectangleF(ev.MarginBounds.Left, ev.MarginBounds.Top, _ 
                             ev.MarginBounds.Width, ev.MarginBounds.Height)
    ev.Graphics.DrawString(resultTextBox.Text.Substring(mStringPos, chars), _
                           fnt, Brushes.Black, rc, _
                           StringFormat.GenericTypographic)

    mStringPos += chars

    ev.HasMorePages = mStringPos < resultTextBox.Text.Length
End Sub

Can someone tell me what I am doing wrong?

A: 

What happens if you do this?

Dim fmt as StringFormat
fmt = StringFormat.GenericTypographic
fmt.SetTabStops( -- put something here --  )
ev.Graphics.DrawString(resultTextBox.Text.Substring(mStringPos, chars), _
                           fnt, Brushes.Black, rc, _
                           fmt)

Does that change things? (Check my syntax - I don't typically do VB.)

jwismar
Nothing........
Daniel