Results 1 to 3 of 3

Thread: How do I print multiple pages?

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Location
    South Africa; Gauteng
    Posts
    2

    Question How do I print multiple pages?

    I can get my printing to work in VB.net, except for one problem, I can't print multiple pages that are different. eg, continut in order from the overflow of the previouse page.

    cause when I insert this code:
    _____________________________
    g.DrawString("Current Trade Data", Me.Font, Brushes.Black, 30 * scalex, 30 * scaley, New StringFormat())
    g.DrawString("Options", Me.Label36.Font, Brushes.Black, 100 * scalex, 50 * scaley, New StringFormat())
    g.DrawString("QUANTITY", Me.Font, Brushes.Black, 30 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("PRICE", Me.Font, Brushes.Black, 100 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("MtoM", Me.Font, Brushes.Black, 170 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("Cumulative", Me.Font, Brushes.Black, 240 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("BookingFee", Me.Font, Brushes.Black, 310 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("STRIKE_PRICE", Me.Font, Brushes.Black, 380 * scalex, 70 * scaley, New StringFormat())
    g.DrawString("Con_TYPE", Me.Font, Brushes.Black, 450 * scalex, 70 * scaley, New StringFormat())
    Dim ia, ib As Integer
    Dim ll, tt As Short
    For ia = 0 To contractOptions.Rows.Count - 1
    For ib = 0 To contractOptions.Columns.Count - 1
    ll = ((ib * 70) + 30) * scalex
    tt = (((ia * 20) + 90) * scaley)
    If (page * (560 * scaley)) < tt Then
    ev.HasMorePages = True
    page = page + 1
    Else
    ev.HasMorePages = False
    End If
    g.DrawString(ConDataGrid.Item(ia, ib), Me.Font, Brushes.Black, ll, tt, New StringFormat())
    Next ib
    Next ia

    _____________________________
    It just prints multiple pages of the same page.

    I get the information out a data set.

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    It prints the same information, because all it will do, is call the _PrintPage event again.

    For example...

    VB Code:
    1. Public Sub PrintDoc_PrintPage
    2.  
    3. g.drawString("HI")
    4. If (page * (560 * scaley)) < tt Then
    5. ev.HasMorePages = True
    6. page = page + 1
    7. Else
    8. ev.HasMorePages = False
    9. End If
    10. End Sub

    Now obviously, it does you no good to keep printing the same stuff again. So you have to devise a way to keep track of what rows have been printed. You can use a higher-scope variable (one that persists outside of _PrintPage sub, that retains the last row of the dataset printed. Then, when PrintPage is called again, it starts printing from the next row, instead of the first row.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Location
    South Africa; Gauteng
    Posts
    2
    I will try that, that is just a small piece of code in a huge nested loops of while, if, and for statements, so it will be kinda tricky.
    But I will keep it in mind.
    Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width