473,378 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to customize PrintPreviewDialog using C#

How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what happens before the document gets displayed in PrintPreviewDialog, i.e. whether entire document gets copied in printer driver spool or only 1 or 2 pages?
please guide
regards
Nov 16 '05 #1
3 22893
Hi

As for code you're on your own, and as for a better answer I'm not sure but since the PrintPreviewDialog uses a PrintPreview Control and since this PrintPreview control exposes all the properties the PrintPreviewDialog gives you such as setting the count of pages to display in the preview, or zoom factor... you can create your own PrintPreviewDialog without much effort.

here's a code sample using the PrintPreviewDialog,

previewDialog.PrintPreviewControl.StartPage = 0; // set which page the preview shows
previewDialog.PrintPreviewControl.Zoom = 1.0; // your previews zoom factor
previewDialog.PrintPreviewControl.Columns = 2; //Sets the page count to display within the preview

now if you created a new windows form and dragged a PrintPreviewControl onto it, set this controls Modifier property to 'internal protected' or higher you can access these properties when you instantiate the form from the main form. Now even dragging a toolbar into this new form you can mockup the original design of the PrintPreviewDialog. You're pretty much done short of adding your buttons, and when you add your buttons you might consider giving their DialogResult property a DialogResult value {OK, Cancel,Yes, No, Retry,Ignore,...} this way you can call the ShowDialog method on this new form to display the modally (Top-most and in control) then you can as well check the user's button press action by checking the returned DialogResult property.

i.e.;

MyPrintPreview printForm = new MyPrintPreview ();
printForm.PrintPreviewControl.Document = printDocument1; // Don't forget the you must attach a PrintDocument object to your Control!!!!
printForm.PrintPreviewControl.StartPage = 0;
printForm.PrintPreviewControl.Zoom = 1.0;
printForm.PrintPreviewControl.Columns = 2;

if (DialogResult.OK == printForm.ShowDialog())
...

Two thing's I'm sure you have probably done, is to make sure you have a PrintDocument object on the form and created the PrintPage event handler with the logic to actually compose your printed output. Without these you'll see nothing but grey or white depending on which of the two you have not done.

rgds,
Trent

"sachin" <an*******@discussions.microsoft.com> wrote in message news:E5**********************************@microsof t.com...
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what happens before the document gets displayed in PrintPreviewDialog, i.e. whether entire document gets copied in printer driver spool or only 1 or 2 pages?
please guide
regards

Nov 16 '05 #2
Thanks for your valuable suggestions Sir
I will definitely follow your instructions. In case of any difficulty, may I trouble you again

regards
Nov 16 '05 #3
I tried the way you suggested but, the document instead of getting displayed in PrintPreviewControl, directly getting copied in printer spool and nothing is displayed in the Preview.
More over copying to spool becomes very slow.
Nov 16 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michael A. Covington | last post by:
By default, my PrintPreviewDialog is coming out too small. What is the best way to control its size and position? Ideally, I'd just like to maximize it. Thanks!
2
by: Randy | last post by:
Hello all, I'm trying to print using PrintPreviewDialog. What's happening is that the PrintPreviewDialog shows the correct information to be printed, but when I click the print icon, it prints a...
0
by: sachin | last post by:
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what...
0
by: sachin | last post by:
How to customize PrintPreviewDialog, such that, addition of a new button, change the functionality of existing button should be possible programatically. Sample code will help a lot. Moreover, what...
0
by: sachin | last post by:
I am trying to customize PrintPreviewDialog for changing functionality of existing buttoms and add a few new buttons using C#, please tell me which dll need to be imported and what are the various...
0
by: Harry J. Smith | last post by:
I am using the PrintPreviewDialog Window Form from the Toolbox. It displays my RichTextBox contents correctly, but when I click on the Print icon on this form it prints one blank page and no text....
1
by: Darrell Wesley | last post by:
Is there anyway to hook the PrintDialog to the printer icon on the PrintPreviewDialog? I know that you can print a document using the PrintDialog but it does not allow previewing and the...
2
by: Richard MSL | last post by:
I am using PrintPreviewDialog to preview a file. There is a button that the user can press, which seems to print the file to the default printer. I would like to capture a click on that button so...
2
by: peter.mcclymont | last post by:
Hi There, I am trying to add the option to close a PrintPreviewDialog using the escape key. Firstly is there an option when creating a PrintPreviewDialog that would allow me to do that? I...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.