Click here to Skip to main content
15,910,797 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings everyone,

I'm developing a VS 2015 C# WinForms application with MySQL and ran into a very annoying issue in regards to printing my form. The form prints perfectly, exactly the way I want, but I've tried everything to make the Print Preview Dialog box close after printing, but to no avail. Any suggestions? I really appreciate your time and help!

Best regards,

JC.

What I have tried:

private void printButton_Click(object sender, EventArgs e)
        {
            printButton.Visible = false;
            printDocument1.DefaultPageSettings.Landscape = true;
            CaptureScreen();
            printDialog1.AllowSelection = true;
            printDialog1.AllowSomePages = true;

            if (printDialog1.ShowDialog() == DialogResult.OK)
            {
                if (printPreviewDialog1.ShowDialog() == DialogResult.OK)
                {
                      printPreviewDialog1.Close();
                      printButton.Visible = true;
                }
            }
        }
Posted
Updated 17-Aug-19 11:47am

1 solution

 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900