Results 1 to 2 of 2

Thread: Margin Problem

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2004
    Location
    LA
    Posts
    57

    Question Margin Problem

    Hello,

    I have problem the margin settings is not working. When I print it ignores the margin settings. Can some one tell me what I’m doing wrong.

    Code:
    Private PrintPageSettings As New PageSettings
    
        Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)
    
            e.Graphics.DrawString(RichTextBox1.Text, RichTextBox1.Font, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top)
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            PrintDialog1.Document = PrintDocument1
            Dim result As DialogResult = PrintDialog1.ShowDialog()
            If result = DialogResult.OK Then
    
                PageSetupDialog1.PageSettings = PrintPageSettings
    
                PageSetupDialog1.PageSettings.Margins.Top *= 0.5
                PageSetupDialog1.PageSettings.Margins.Bottom *= 0.5
                PageSetupDialog1.PageSettings.Margins.Left *= 0.5
                PageSetupDialog1.PageSettings.Margins.Right *= 0.5
    
                PrintDocument1.Print()
            End If
        End Sub

    Thank you.

  2. #2
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    Do you mean that it doesn't wrap for you? You have to manage this with code and determine when you need a new page, etc. Otherwise, I have had cases where a particular printer driver was at fault, so I would also suggest that you try it on more than 1 printer (if you haven't already).

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