problem with printer button in print preview -

Posted on 2012-08-23
Last Modified: 2012-08-23
The printer button on the PrintPreviewDialog1 doesn't work. I have my report up in preview mode and I want to be able to click the little printer button (printer icon) in the top left of the print preview control and have the report that is being previewed, print. It doesn't. What I get is very strange. If the report has three pages what prints is a 4th page with just headings. Of course I don't want this page, I want the three pages of the report.
 I've done a lot of googling and searching as I believe others must have had, and solved, this problem but I can't find any answers.
 If I have to put code 'behind' the button I know the code to put there (m_PrintDocument.Print()). I just don't know how to put this code 'behind' this button.
 Any guidance would be greatly appreciated. .
Question by:kylucky
    LVL 83

    Accepted Solution


    Author Comment

    Thank you CC.  My problem is exactly what their problem was.  I did learn from their experience and solution but I'm still not there yet.
    The way I understand the first person's problem was that he/she was using .dispose in the method.  I am not doing this so .dispose is not the cause of my problem.

    On the second thread you referenced they suggested replacing the button and using reflection.  I'm going to study this more because right now I have no idea what reflection is.  I've never used it.  

    The third thread suggests a whole new way to solve the problem; the 'coolprintpreviewdialog' method.   He did this in 'C' and I really don't know 'C' so this approach is probably not viable for me.

    I have made progress.   Since I was getting page 4 of a three page report I figured I needed to set my page number back to 0 at the end of the preview.   So, when the embedded print button was clicked, and it would go thru the printDocument method it would have the page number correct.   This improved things; no more page 4.   But, it only printed one page.  If the report had 2 pages or 100 pages; I only get page 1.   Now, I will admit, page 1 is better than page 4 of a three page report but it's not there yet.

    If you have any other ideas I would appreciate them and in the meantime I'm going to study more closely the second thread you sent and see if I can understand that approach and reflection.   I do know that if I can put my own button on this preview screen then I can definitely make the report print just as I want it to.

    Author Comment

    I studied the threads you provided CC and none were possible for me.  They would take days and days of study and trying and it just isn't worth it.  I just don't have a week(s) to devote to a print button.   I'm going to close this out.  

    I did learn from this.   I learned that what should be a very simple matter; isn't.

    And I have one observation.   Can you believe Microsoft would put a print button on a preview form and not have it print out what is being previewed?   There is no logical explanation for this that I can think of.   Every other button on that control does just what it is supposed to do.   But the print button - nothing useful.  They don't program it and they don't even give the developer a way to program it.  What they do offer is an opportunity for smart programmers to see how creative they can be in their attempts to develop a workaround for something Microsoft should have done.  Maybe in VB - 2018 Microsoft will get around to having the print button actually print something.

    Thanks for pointing me to these threads CC.

    Author Closing Comment

    please see my last post.


    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now