Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

C# software print settings

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you the "C# software print settings", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn the "C# software print settings" this article.

We will encounter some problems in the actual implementation of C# print development, so how to solve these problems of C# print settings becomes very practical. so what are the common problems in implementing C# printing, C# print preview, C# print settings and so on? Let's talk about solving the problem of the change of page margin value of C# print setup control:

Protected virtual PageSettings ShowPageSetupDialog (PrintDocument printDocument) {/ / checks whether printDocument is empty, and throws an exception ThrowPrintDocumentNullException (printDocument) if it is empty; / / declares the return value PageSettings PageSettings ps = new PageSettings (); / / declares and instantiates PageSetupDialog PageSetupDialog psDlg = new PageSetupDialog (); ps = printDocument.DefaultPageSettings; try {/ / the default settings for related documents and document pages psDlg.Document = printDocument; Margins mg = printDocument.DefaultPageSettings.Margins If (System.Globalization.RegionInfo.CurrentRegion.IsMetric) {mg = PrinterUnitConvert.Convert (mg, PrinterUnit.Display, PrinterUnit.TenthsOfAMillimeter);} / / back up the DefaultPageSettings of the printed document, / / because it will change after conversion, / / and the settings dialog box will not display the original value PageSettings psPrintDocumentBack = (PageSettings) (printDocument.DefaultPageSettings.Clone ()) correctly after clicking the cancel button; psDlg.PageSettings = psPrintDocumentBack; / / printDocument.DefaultPageSettings / / if you cancel the dialog box when using printDocument, restore psDlg.PageSettings.Margins = mg; / / display the dialog box DialogResult result = psDlg.ShowDialog (); if (result = = DialogResult.OK) {ps = psDlg.PageSettings; printDocument.DefaultPageSettings = psDlg.PageSettings;} else {}} catch (System.Drawing.Printing.InvalidPrinterException e) {ShowInvalidPrinterException (e);} catch (Exception ex) {ShowPrinterException (ex) } finally {psDlg.Dispose (); psDlg = null;} return ps;} these are all the contents of the article "print setup of C# Software". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report