473,769 Members | 7,810 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to customize PrintPreviewDia log using C#

How to customize PrintPreviewDia log, 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 PrintPreviewDia log, 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 22975
Hi

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

here's a code sample using the PrintPreviewDia log,

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

now if you created a new windows form and dragged a PrintPreviewCon trol 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 PrintPreviewDia log. 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.Print PreviewControl. Document = printDocument1; // Don't forget the you must attach a PrintDocument object to your Control!!!!
printForm.Print PreviewControl. StartPage = 0;
printForm.Print PreviewControl. Zoom = 1.0;
printForm.Print PreviewControl. Columns = 2;

if (DialogResult.O K == printForm.ShowD ialog())
...

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*******@disc ussions.microso ft.com> wrote in message news:E5******** *************** ***********@mic rosoft.com...
How to customize PrintPreviewDia log, 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 PrintPreviewDia log, 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 PrintPreviewCon trol, 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
14438
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
5869
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 blank page. If I comment out the printPreviewDialog1.ShowDialog(); and just do a printDocument1.Print(); instead, it prints all the pages like a champ. Anyone know what I'm doing wrong? Thanks
0
414
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 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
0
1287
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 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 sachi
0
1052
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 methods available or need to be overriden for the same. Sample code will help a lot regards
0
1597
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. How can I fix this to print the text that is being displayed? Here is the code I use to bring up the form: string stringText = helpTextOut.Text;
1
5704
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 PrintPreview dialog does not allow you to select a printer - is there a good and simple way to get around these problems. My users would like to select a specific printer while looking at the Preview window.
2
9875
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 that I can present a PrintDialog, print some files in a special way, etc. But there does not seem to be an event among the PrintPreviewDialog members to do this? Or perhaps I missed it? I would appreciate any suggestions. Thanks.
2
2076
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 have tried to inherit the PrintPreviewDialog and override the key events. That didn't work.
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9865
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3567
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.