dcsimg
Results 1 to 4 of 4

Thread: Gray Background on Print Preview

  1. #1

    Thread Starter
    New Member Signako's Avatar
    Join Date
    Dec 2017
    Posts
    3

    Gray Background on Print Preview

    I am having a bit of a problem printing, and using print preview. First of all I am using the RichTextBoxPrintCtrl Class found here at
    https://support.microsoft.com/en-us/...ng-visual-basi

    This is the Code for my PrintDocument1.PrintPage
    Code:
     Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            On Error Resume Next                                        '-On Error Resume Function-'
            checkPrint = RichTextBoxPrintCtrl1.Print(checkPrint, RichTextBoxPrintCtrl1.TextLength, e)
            If checkPrint < RichTextBoxPrintCtrl1.TextLength Then
                e.HasMorePages = True
    
            Else
                e.HasMorePages = False
    
            End If
    Picture of the Result
    Name:  TEst.png
Views: 136
Size:  6.2 KB

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,661

    Re: Gray Background on Print Preview

    The very first thing to do is get rid of 'On Error Resume Next' and never use it again. That basically says "if something goes wrong then just carry on regardless and don't tell anyone". It may not be related but if you specifically tell your code to keep going even if something breaks then getting results that don't look right shouldn't really be a surprise.

    As for the issue specifically, can we assume that there is no grey background in the RichTextBox itself?
    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
    New Member Signako's Avatar
    Join Date
    Dec 2017
    Posts
    3

    Re: Gray Background on Print Preview

    Yes there is not a gray background in the RichTextBox.

  4. #4

    Thread Starter
    New Member Signako's Avatar
    Join Date
    Dec 2017
    Posts
    3

    Re: Gray Background on Print Preview

    I found the problem, seems by using Windows System Properties Adjust for best Performance for Visual Effects, would cause this error when trying to print preview. I switched to a custom visual effect, and the gray box is gone. -Edit by the way my OS is Windows 7 Service Pack 1

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width