?
Solved

problem with printer button in print preview - vb.net

Posted on 2012-08-23
4
Medium Priority
?
654 Views
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. .
0
Comment
Question by:kylucky
  • 3
4 Comments
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 38325661
0
 

Author Comment

by:kylucky
ID: 38325781
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.
0
 

Author Comment

by:kylucky
ID: 38327504
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.
0
 

Author Closing Comment

by:kylucky
ID: 38327507
please see my last post.

Thanks.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

829 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