Hello --

When using the PrintForm component in VB.Net 2010 I would like to change the back color of the form from black to white just prior to printing to preview. Then once the print preview window is closed the back color returns to black. Here is the code I am using to print to preview

 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()            
    End Sub

Here is a variation of what I tried:

 Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Me.BackColor = Color.White
        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
        Me.BackColor = Color.Black
    End Sub

Any help would be greatly appreciated.

Thank you!

Sorry. The form has a back color of black. I want to change the back color to white, PrintToPreview, then return the form to a black back color (I don't want to print the black back color). Not sure if this is possible, but the different attempts I have tried have not worked.

Thank you again.

You need to insert a me.refresh as so:

 Me.BackColor = Color.White
 me.refresh
        PrintForm1.PrintAction = Printing.PrintAction.PrintToPreview
        PrintForm1.Print()
        Me.BackColor = Color.Black
        me.refresh

Minimalist --

Thank you very much. Exactly what I needed. It worked perfectly.

Best regards!

This question has already been answered. Start a new discussion instead.