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!

What is question?

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.

But how have they not worked? Errors? No change?

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!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.