Results 1 to 3 of 3

Thread: printing

  1. #1

    Thread Starter
    Lively Member Iain Wicks's Avatar
    Join Date
    Jun 2005
    Location
    Tring, Hertfordshire
    Posts
    88

    printing

    I have some code which will divide my page into 2 x 3. I want to print picturebox1.image in all six rectangles on the page but I am trying to figure out where to put the following line.

    ev.Graphics.DrawImage(PicImage.Image........

    Below is the code for dividing the page into 6. I am sure this is easy, it's just that i am not getting it!!


    VB Code:
    1. Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)
    2.  
    3.  
    4.  
    5. Dim rowCount As Integer = 3 'The number of rows into which to divide the printed page
    6.  
    7. Dim colCount As Integer = 2 'The number of columns into which to divide the printed page
    8.  
    9. Dim regions(rowCount - 1, colCount - 1) As RectangleF 'The regions of the printed page.
    10.  
    11. Dim regionHeight As Single = Convert.ToSingle(e.MarginBounds.Height / rowCount) 'The height of each region.
    12.  
    13. Dim regionWidth As Single = Convert.ToSingle(e.MarginBounds.Width / colCount) 'The width of each region.
    14.  
    15. For rowIndex As Integer = 0 To regions.GetUpperBound(0) Step 1
    16.  
    17. For colIndex As Integer = 0 To regions.GetUpperBound(1) Step 1
    18.  
    19. regions(rowIndex, colIndex) = New RectangleF(ev.MarginBounds.X + rowIndex * regionWidth, _
    20.  
    21. ev.MarginBounds.Y + colIndex * regionHeight, _
    22.  
    23. regionWidth, _
    24.  
    25. regionHeight)
    26.  
    27. Next colIndex
    28.  
    29. Next rowIndex
    30.  
    31. End Sub

    Maybe i need another FOR NEXT section?

    THANKS

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: printing

    Each iteration of the inner loop creates a RectangleF structure. That's where you need to call DrawImage and pass that RectangleF as a parameter. You don't really even need the array because once you've drawn the image you don't need the RectangleF anymore.

    Also, can I suggest indenting your code? It makes it far more readable.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member Iain Wicks's Avatar
    Join Date
    Jun 2005
    Location
    Tring, Hertfordshire
    Posts
    88

    Re: printing

    Thanks

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