本文整理汇总了C#中System.Windows.Forms.PrintPreviewDialog类的典型用法代码示例。如果您正苦于以下问题:C# PrintPreviewDialog类的具体用法?C# PrintPreviewDialog怎么用?C# PrintPreviewDialog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PrintPreviewDialog类属于System.Windows.Forms命名空间,在下文中一共展示了PrintPreviewDialog类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: PrintClass
/// <summary>
/// 打印信息的初始化
/// </summary>
/// <param datagrid="DataGridView">打印数据</param>
/// <param PageS="int">纸张大小</param>
/// <param lendscape="bool">是否横向打印</param>
public PrintClass(DataGridView datagrid, int PageS, bool lendscape)
{
this.datagrid = datagrid;//获取打印数据
this.PageSheet = PageS;//纸张大小
printdocument = new PrintDocument();//实例化PrintDocument类
pagesetupdialog = new PageSetupDialog();//实例化PageSetupDialog类
pagesetupdialog.Document = printdocument;//获取当前页的设置
printpreviewdialog = new PrintPreviewDialog();//实例化PrintPreviewDialog类
printpreviewdialog.Document = printdocument;//获取预览文档的信息
printpreviewdialog.FormBorderStyle = FormBorderStyle.Fixed3D;//设置窗体的边框样式
//横向打印的设置
if (PageSheet >= 0)
{
if (lendscape == true)
{
printdocument.DefaultPageSettings.Landscape = lendscape;//横向打印
}
else
{
printdocument.DefaultPageSettings.Landscape = lendscape;//纵向打印
}
}
pagesetupdialog.Document = printdocument;
printdocument.PrintPage += new PrintPageEventHandler(this.printdocument_printpage);//事件的重载
}
开发者ID:mahuidong,项目名称:c-1200-II,代码行数:31,代码来源:PrintClass.cs
示例2: print
public void print()
{
PrintDialog pd = new PrintDialog();
PrintDocument pdoc = new PrintDocument();
PrinterSettings ps = new PrinterSettings();
Font font =new Font("Arial",12);
PaperSize psize = new PaperSize("Custome", 100, 200);
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.DefaultPageSettings.PaperSize.Height = 320;
pdoc.DefaultPageSettings.PaperSize.Width = 200;
pdoc.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.Document = pdoc;
result = ppd.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
开发者ID:neyosuraj,项目名称:thisistestRepository,代码行数:28,代码来源:orderlist.cs
示例3: print
public void print()
{
PrintDialog pd = new PrintDialog();
pdoc = new PrintDocument();
PrinterSettings ps = new PrinterSettings();
Font font = new Font("Courier New", 15);
PaperSize psize = new PaperSize("Custom", 300, 100);
ps.DefaultPageSettings.PaperSize = psize;
pd.Document = pdoc;
pd.Document.DefaultPageSettings.PaperSize = psize;
pdoc.DefaultPageSettings.PaperSize = psize;
pdoc.PrintPage += new PrintPageEventHandler(pdoc_PrintPage);
DialogResult result = pd.ShowDialog();
if (result == DialogResult.OK)
{
PrintPreviewDialog pp = new PrintPreviewDialog();
pp.Document = pdoc;
result = pp.ShowDialog();
if (result == DialogResult.OK)
{
pdoc.Print();
}
}
}
开发者ID:hydrohead,项目名称:MWSZonBarcode,代码行数:30,代码来源:Printing.cs
示例4: Execute
public override void Execute()
{
printDocument = new PrintDocument();
printDocument.OriginAtMargins = true;
printDocument.BeginPrint += new PrintEventHandler(printDocument_BeginPrint);
printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
Dictionary<String, Object> paperSettings = Printing.getPaperSettings(grtArguments);
printDocument.DefaultPageSettings.Landscape = (string)paperSettings["orientation"] == "landscape";
// Sizes must be given in inch * 100 (sigh).
int paperWidth = (int)Math.Round((double)paperSettings["width"] / 0.254);
int paperHeight = (int)Math.Round((double)paperSettings["height"] / 0.254);
PaperSize paperSize = new PaperSize("Ignored anyway", paperWidth, paperHeight);
if ((bool)paperSettings["marginsSet"])
printDocument.DefaultPageSettings.Margins =
new Margins((int)paperSettings["marginLeft"], (int)paperSettings["marginRight"],
(int)paperSettings["marginTop"], (int)paperSettings["marginBottom"]);
System.Windows.Forms.PrintPreviewDialog preview = new System.Windows.Forms.PrintPreviewDialog();
preview.Document = printDocument;
preview.UseAntiAlias = true;
preview.ShowDialog();
}
开发者ID:abibell,项目名称:mysql-workbench,代码行数:28,代码来源:PrintPreviewDialog.cs
示例5: btnPrint_Click
private void btnPrint_Click(object sender, EventArgs e)
{
gcOptions.Visible = false;
using (System.Drawing.Printing.PrintDocument printDocument = new System.Drawing.Printing.PrintDocument())
{
printDocument.PrintPage += printDocument_PrintPage;
printDocument.DefaultPageSettings.Landscape = true;
printDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("FalseX", 500, 1000);
//Resize
Size = new Size(974, 507);
CaptureScreen();
try
{
//printDocument.Print();
PrintPreviewDialog PPdlg = new PrintPreviewDialog() { Document = printDocument };
PPdlg.Show();
}
catch (Exception ex)
{
Program.ShowMsg(ex.Message, true, this);
Program.Logger.LogThis(null, Text, FXFW.Logger.OpType.fail, ex, null, this);
}
}
Size = new Size(974, 589);
gcOptions.Visible = true;
}
开发者ID:EgyFalseX-EESoft-WinForm,项目名称:School,代码行数:27,代码来源:QryWeekTeacherTableFrm.cs
示例6: MapOutPut
public MapOutPut(AxPageLayoutControl pagecontrol)
{
axPageLayoutControl1 = pagecontrol;
printDialog1 = new System.Windows.Forms.PrintDialog(); //create a print dialog object
InitializePageSetupDialog(); //intitialize the page setup dialog
comboBox1.Items.Add("esriPageMappingTile");
comboBox1.Items.Add("esriPageMappingCrop");
comboBox1.Items.Add("esriPageMappingScale");
comboBox1.SelectedIndex = 0;
// create a new PrintPreviewDialog using constructor
printPreviewDialog1 = new PrintPreviewDialog();
//set the size, location, name and the minimum size the dialog can be resized to
printPreviewDialog1.ClientSize = new System.Drawing.Size(800, 600);
printPreviewDialog1.Location = new System.Drawing.Point(29, 29);
printPreviewDialog1.Name = "PrintPreviewDialog1";
printPreviewDialog1.MinimumSize = new System.Drawing.Size(375, 250);
//set UseAntiAlias to true to allow the operating system to smooth fonts
printPreviewDialog1.UseAntiAlias = true;
//associate the event-handling method with the document's PrintPage event
this.document.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(document_PrintPage);
}
开发者ID:xfgxfg,项目名称:CropWatchField,代码行数:25,代码来源:MapOutPut.cs
示例7: buttonPrintImage_Click
private void buttonPrintImage_Click(object sender, EventArgs e)
{
try
{
PrintDialog printDialog = new PrintDialog();
printDialog.Document = this.printDocument1;
if (printDialog.ShowDialog() != DialogResult.OK)
{
throw new Exception();
}
/*
PageSetupDialog pageSetupDialog = new PageSetupDialog();
pageSetupDialog.Document = printDocument1;
if (pageSetupDialog.ShowDialog() != DialogResult.OK)
{
throw new Exception();
}
*/
PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog();
printPreviewDialog.Document = this.printDocument1;
printPreviewDialog.ShowDialog();
}
catch (Exception)
{
MessageBox.Show("打印已经取消");
}
}
开发者ID:FieldSoft-HelloClyde,项目名称:MedicalRecordManagementSystem,代码行数:28,代码来源:ImageWindow.cs
示例8: printPreview
public void printPreview(PrinteModel model)
{
if (model != null)
{
printModel = model;
}
else
{
return;
}
try
{
init();
PrintPreviewDialog previewDialog = new PrintPreviewDialog();
previewDialog.Document = docToPrint;
var result = previewDialog.ShowDialog();
if (result == DialogResult.OK)
{
docToPrint.Print();
}
}
catch (Exception ex)
{
}
}
开发者ID:vigorlu,项目名称:Mova.Printer,代码行数:26,代码来源:PrintHelper.cs
示例9: InitializeComponent
private void InitializeComponent()
{
this.printDocument1 = new System.Drawing.Printing.PrintDocument();
//
//Main DataSet Initialization
//
this.printPreviewDialog1 = new PrintPreviewDialog();
this.maindataset = new SupremeTransport.maindataset();
//
//Table Adapter Initialization
//
this.mainbillTableAdapter = new SupremeTransport.maindatasetTableAdapters.mainbillTableAdapter();
this.billTableAdapter = new SupremeTransport.maindatasetTableAdapters.billTableAdapter();
//
// printDocument1
//
this.printDocument1.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.printDocument1_PrintPage);
//
// printPreviewDialog1
//
this.printPreviewDialog1.AutoScrollMargin = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.AutoScrollMinSize = new System.Drawing.Size(0, 0);
this.printPreviewDialog1.ClientSize = new System.Drawing.Size(400, 300);
this.printPreviewDialog1.Enabled = true;
this.printPreviewDialog1.Name = "printPreviewDialog1";
this.printPreviewDialog1.Visible = false;
}
开发者ID:EdiCarlos,项目名称:MyPractices,代码行数:27,代码来源:PrintingClass.cs
示例10: bPay_Click
private void bPay_Click(object sender, EventArgs e)
{
DB.Instance.Insert("order", new Parameter("customer_id", cid), new Parameter("dt", DateTime.Now), new Parameter("status", OrderStatus.New));
uint oid = 0;
using (MySqlDataReader reader = DB.Instance.SelectReader("select max(id) from order"))
{
if(reader != null && reader.Read()){
oid = reader.GetUInt32(0);
}
}
foreach (var item in Role.Instance.ShopCart)
{
DB.Instance.Insert("order_inventory", new Parameter("order_id", oid), new Parameter("inventory_id", item.ID), new Parameter("amount", item.Qty));
}
var dr = MessageBox.Show("Order Placed. Would you like to pay now?", "Payment", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (dr == DialogResult.Yes)
{
new Payment().ShowDialog();
}
else if(dr == DialogResult.No)
{
var ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
ppd.Document = pd;
pd.PrintPage += Pd_PrintPage;
ppd.ShowDialog();
}
}
开发者ID:redlive,项目名称:csis3275,代码行数:28,代码来源:Checkout.cs
示例11: PrintPreviewTree
/// <summary>
/// Shows a PrintPreview dialog displaying the Tree control passed in.
/// </summary>
/// <param name="tree">TreeView to print preview</param>
/// <param name="reportTitle"></param>
public void PrintPreviewTree(TreeView tree, string reportTitle)
{
this.title = reportTitle;
this.PrepareTreeImage(tree);
var pp = new PrintPreviewDialog { Document = this.printDoc };
pp.Show();
}
开发者ID:jilamilani,项目名称:PrintTreeView,代码行数:12,代码来源:PrintHelper.cs
示例12: PrintTokens
public void PrintTokens(List<TokenPrint> tokens, Form parentDialog, string PrinterName, bool showPrintPreview)
{
_tokensToPrint = tokens;
_pageCounter = 0;
//bool showPrintPreview = true;
PrintDocument pd = new PrintDocument();
PrintDocument pd1 = new PrintDocument();
pd.DefaultPageSettings.PaperSize = paperSize;
pd.PrintPage += printDoc_PrintPage;
pd.PrinterSettings.PrinterName = PrinterName;
//ToDo: can remove preview in the actual production.
if (showPrintPreview)
{
var ppDlg = new PrintPreviewDialog();
ppDlg.SetBounds(30, 30, 1024, 500);
ppDlg.PrintPreviewControl.AutoZoom = true;
ppDlg.PrintPreviewControl.Zoom = 0.75;
ppDlg.Document = pd;
var dr = ppDlg.ShowDialog(parentDialog);
}
else
{
pd.Print();
}
}
开发者ID:akhilnaruto,项目名称:WinApp,代码行数:27,代码来源:PrintHelper.cs
示例13: ShowPrintPreviewDialog
/// <summary>
/// Shows the print preview dialog</summary>
public void ShowPrintPreviewDialog()
{
PrintPreviewDialog dialog = new PrintPreviewDialog();
PrintDocument printDocument = GetPrintDocument();
dialog.Document = printDocument;
dialog.ShowDialog();
}
开发者ID:JanDeHud,项目名称:LevelEditor,代码行数:9,代码来源:StandardPrintCommands.cs
示例14: Execute
/// <summary>
/// A utility method to print preview and print an Aspose.Words document.
/// </summary>
internal static void Execute(Document document)
{
// This operation can take some time (for the first page) so we set the Cursor to WaitCursor.
Cursor cursor = Cursor.Current;
Cursor.Current = Cursors.WaitCursor;
PrintPreviewDialog previewDlg = new PrintPreviewDialog();
// Initialize the Print Dialog with the number of pages in the document.
PrintDialog printDlg = new PrintDialog();
printDlg.AllowSomePages = true;
printDlg.PrinterSettings = new PrinterSettings();
printDlg.PrinterSettings.MinimumPage = 1;
printDlg.PrinterSettings.MaximumPage = document.PageCount;
printDlg.PrinterSettings.FromPage = 1;
printDlg.PrinterSettings.ToPage = document.PageCount;
// Restore cursor.
Cursor.Current = cursor;
// Interesting, but PrintDialog will not show and will always return cancel
// if you run this application in 64-bit mode.
if (!printDlg.ShowDialog().Equals(DialogResult.OK))
return;
// Create the Aspose.Words' implementation of the .NET print document
// and pass the printer settings from the dialog to the print document.
AsposeWordsPrintDocument awPrintDoc = new AsposeWordsPrintDocument(document);
awPrintDoc.PrinterSettings = printDlg.PrinterSettings;
// Pass the Aspose.Words' print document to the .NET Print Preview dialog.
previewDlg.Document = awPrintDoc;
previewDlg.ShowDialog();
}
开发者ID:nancyeiceblue,项目名称:Aspose_Words_NET,代码行数:38,代码来源:Preview.cs
示例15: filePrintPreviewMenuItem_Click
private void filePrintPreviewMenuItem_Click(Object sender ,
EventArgs e)
{
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = printDoc;
dlg.ShowDialog();
}
开发者ID:hitswa,项目名称:winforms,代码行数:7,代码来源:swf-printing.cs
示例16: Print_DataGridView
public static void Print_DataGridView(DataGridView dgv1, string printTitle, bool printAllRows, bool fitToPageWidth)
{
PrintPreviewDialog ppvw;
try
{
// Getting DataGridView object to print
dgv = dgv1;
// Getting all Coulmns Names in the DataGridView
AvailableColumns.Clear();
foreach (DataGridViewColumn c in dgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
// Showing the PrintOption Form
//PrintOptions dlg = new PrintOptions(AvailableColumns);
//if (dlg.ShowDialog() != DialogResult.OK) return;
PrintTitle = printTitle;
PrintAllRows = printAllRows;
FitToPageWidth = fitToPageWidth;
SelectedColumns = AvailableColumns;
RowsPerPage = 0;
ppvw = new PrintPreviewDialog();
PageSetupDialog psd = new PageSetupDialog();
psd.Document = printDoc;
psd.ShowDialog();
printDoc.DefaultPageSettings = psd.PageSettings;
ppvw.Document = printDoc;
// Showing the Print Preview Page
printDoc.BeginPrint += new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
//printDoc.QueryPageSettings += new System.Drawing.Printing.QueryPageSettingsEventHandler(printDoc_QueryPageSettings);
if (ppvw.ShowDialog() != DialogResult.OK)
{
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
return;
}
// Printing the Documnet
printDoc.Print();
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
}
}
开发者ID:Avaruz,项目名称:Avaruz.FrameWork,代码行数:60,代码来源:PrintDV.cs
示例17: GetPrinters_Click
private void GetPrinters_Click(object sender, EventArgs e)
{
//PrintDocument pd = new PrintDocument();
//pd.DefaultPageSettings.Bounds = new
//pd.Print();
PrintPreviewDialog ppd = new PrintPreviewDialog();
PrintDocument pd = new PrintDocument();
//设置边距
Margins margin = new Margins(200, 20, 20, 0);
pd.DefaultPageSettings.Margins = margin;
//纸张设置默认
PaperSize pageSize = new PaperSize("First custom size", getYc(58), 100);
pd.DefaultPageSettings.PaperSize = pageSize;
//打印事件设置
pd.PrintPage += pd_PrintPage;
ppd.Document = pd;
ppd.ShowDialog();
//try
//{
// pd.Print();
//}
//catch (Exception ex)
//{
// MessageBox.Show(ex.Message, "打印出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
// pd.PrintController.OnEndPrint(pd, new PrintEventArgs());
//}
}
开发者ID:ysjr-2002,项目名称:DeviceTest,代码行数:28,代码来源:FrmDefaultPrint.cs
示例18: Print_DataGridView
private static int TotalWidth; // Summation of Columns widths
#endregion Fields
#region Methods
public static void Print_DataGridView(DataGridView dgv1)
{
PrintPreviewDialog ppvw;
try
{
// Getting DataGridView object to print
dgv = dgv1;
// Getting all Coulmns Names in the DataGridView
AvailableColumns.Clear();
foreach (DataGridViewColumn c in dgv.Columns)
{
if (!c.Visible) continue;
AvailableColumns.Add(c.HeaderText);
}
// Showing the PrintOption Form
PrintOptions dlg = new PrintOptions(AvailableColumns);
if (dlg.ShowDialog() != DialogResult.OK) return;
PrintAllRows = dlg.PrintAllRows;
FitToPageWidth = dlg.FitToPageWidth;
SelectedColumns = dlg.GetSelectedColumns();
RowsPerPage = 0;
ppvw = new PrintPreviewDialog();
ppvw.Document = printDoc;
// Showing the Print Preview Page
printDoc.BeginPrint +=new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage +=new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
printDoc.DefaultPageSettings.Landscape = true;
PaperSize paperSize = new PaperSize("Letter", 850, 1100);
paperSize.RawKind = (int)PaperKind.Custom;
printDoc.DefaultPageSettings.PaperSize = paperSize;
if (ppvw.ShowDialog() != DialogResult.OK)
{
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
return;
}
// Printing the Documnet
printDoc.DefaultPageSettings.Landscape = true;
printDoc.DefaultPageSettings.PaperSize = paperSize;
printDoc.Print();
printDoc.BeginPrint -= new System.Drawing.Printing.PrintEventHandler(PrintDoc_BeginPrint);
printDoc.PrintPage -= new System.Drawing.Printing.PrintPageEventHandler(PrintDoc_PrintPage);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
finally
{
}
}
开发者ID:jayoreilly,项目名称:Geoex,代码行数:65,代码来源:PrintDGV.cs
示例19: PrintPreview
public void PrintPreview()
{
PrintPreviewDialog dlg = new PrintPreviewDialog();
dlg.Document = printDocument;
dlg.WindowState = FormWindowState.Maximized;
dlg.ShowInTaskbar = false;
dlg.ShowDialog();
}
开发者ID:sagar1589,项目名称:Delta.Cryptography,代码行数:8,代码来源:PrintableRichTextBox.cs
示例20: PrintPreview
public DialogResult PrintPreview()
{
PrintPreviewDialog ppd = new PrintPreviewDialog();
ppd.WindowState = FormWindowState.Maximized;
ppd.Document = _printDocument;
return ppd.ShowDialog();
}
开发者ID:dbbotkin,项目名称:PrimeComm,代码行数:8,代码来源:Printing.cs
注:本文中的System.Windows.Forms.PrintPreviewDialog类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论