473,395 Members | 1,516 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,395 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 22903
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...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.