private bool SetupThePrinting() { string Text; printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) return false; printDocument1.DocumentName = "Client Statement"; printDocument1.PrinterSettings = printDialog1.PrinterSettings; printDocument1.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); Text = txtCBName.Text + Environment.NewLine + txtStateAccType.Text + Environment.NewLine + "" + Environment.NewLine + txtAddress.Text + Environment.NewLine + "" + Environment.NewLine + "From date: " + Environment.NewLine + "To date: " + Environment.NewLine + "Print date: " + DateTime.Today.ToShortDateString() + Environment.NewLine + "" + Environment.NewLine + "Account number: " + txtStateAccNumber.Text + " " + txtStateAccType.Text + Environment.NewLine + "" + Environment.NewLine + ""; //if (MessageBox.Show("Do you want the report to be centered on the page", // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, // MessageBoxIcon.Question) == DialogResult.Yes) // MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, // printDocument1, true, true, "Statement", new Font("Tahoma", 18, // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); //else MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, printDocument1, false, true, Text, new Font("Tahoma", 8, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return true; }
/// PrintDocument printDocument1; private bool SetUpTherinting() { PrintDialog MyPrintDialog = new PrintDialog(); printDocument1 = new PrintDocument(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } printDocument1.DocumentName = "Reporte"; printDocument1.PrinterSettings = MyPrintDialog.PrinterSettings; printDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(10, 10, 10, 10); printDocument1.DefaultPageSettings.Landscape = true; if (MessageBox.Show("Desea ver el reporte centrado en la pagina", "HalcoNET", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(gridLineas, printDocument1, true, true, "MI REPORTE", new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } else { MyDataGridViewPrinter = new DataGridViewPrinter(gridLineas, printDocument1, false, true, "MI REPORTE", new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } return(true); }
private void OnBuildClick(object sender, EventArgs e) { logger.Info("Нажата кнопка 'построить', количество строк массива " + _view.NumRows + ", количество столбцов " + _view.NumColumns + "."); var model = SnakeService.CalculateModel(_view.NumColumns, _view.NumRows); IPrinter dgPrinter = new DataGridViewPrinter { DataGrid = _view.MyDataGridView }; dgPrinter.Print(model); var result = MessageBox.Show("Сохранить в файл?", "Сохранение в файл", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result != DialogResult.OK) { logger.Info("Отказ сохранить построенный массив в файл"); return; } if (string.IsNullOrEmpty(_view.FilePath)) { logger.Info("Ошибка сохранения массива в файл - не указан путь."); MessageBox.Show("Файл не указан", "Сохранение файла", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IPrinter fPrinter = new FilePrinter { Path = _view.FilePath }; fPrinter.Print(model); }
private bool SetupThePrinting() { //PrintDialog MyPrintDialog = new PrintDialog(); printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Libro de I.V.A. - Ventas"; MyPrintDocument.PrinterSettings = printDialog1.PrinterSettings; MyPrintDocument.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(12, 12, 20, 20); MyDataGridViewPrinter = new DataGridViewPrinter(DG_Facturas, MyPrintDocument, false, true, "Libro de I.V.A. - Ventas - Periodo: " + Txt_Periodo.Text, new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting() { //PrintDialog MyPrintDialog = new PrintDialog(); printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Caja"; MyPrintDocument.PrinterSettings = printDialog1.PrinterSettings; MyPrintDocument.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(12, 12, 20, 20); MyDataGridViewPrinter = new DataGridViewPrinter(DG_Datos, MyPrintDocument, false, true, "Caja : (" + DT_Desde.Value.ToString("dd/MM/yy") + " - " + DT_Hasta.Value.ToString("dd/MM/yy") + ")", new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting(DataGridView grd, string docName, string title) { PrintDialog printDlg = new PrintDialog(); printDlg.AllowCurrentPage = false; printDlg.AllowPrintToFile = false; printDlg.AllowSelection = false; printDlg.AllowSomePages = false; printDlg.PrintToFile = false; printDlg.ShowHelp = false; printDlg.ShowNetwork = false; if (printDlg.ShowDialog() != DialogResult.OK) { return(false); } printDocument1.DocumentName = docName; printDocument1.PrinterSettings = printDlg.PrinterSettings; printDocument1.DefaultPageSettings = printDlg.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); _dataGridViewPrinter = new DataGridViewPrinter(grd, printDocument1, true, true, title, new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting() { //PrintDialog MyPrintDialog = new PrintDialog(); printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Saldos"; MyPrintDocument.PrinterSettings = printDialog1.PrinterSettings; MyPrintDocument.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(12, 12, 20, 20); MyDataGridViewPrinter = new DataGridViewPrinter(DG_Saldo, MyPrintDocument, false, true, "Saldos de " + Datos.Tercero_tipo.GetTercero_tipo(_TipoTercero.ToString()).ListaTercero_tipo[0].Descripcion_Tercero_Tipo, new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private void 打印Button_Click(object sender, EventArgs e) {//打印水电气费信息 string v_计费年份 = this.计费年份ComboBox.Text.Trim(); string v_计费月份 = this.计费月份ComboBox.Text.Trim(); string title = string.Empty; if (v_计费月份 != "全年") { title = string.Format("{0}{1}年{2}月物业费总清单", this.小区名称ComboBox.Text, v_计费年份, v_计费月份); } else { title = string.Format("{0}{1}年全年物业费总清单", this.小区名称ComboBox.Text, v_计费年份); } printDocument.DocumentName = title; printDocument.PrinterSettings = printDialog.PrinterSettings; printDocument.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; printDocument.DefaultPageSettings.Margins = new Margins(6, 6, 10, 10); print = new DataGridViewPrinter(this.水电气费DataGridView, printDocument, title); PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.WindowState = FormWindowState.Maximized; printPreviewDialog.Icon = new Icon(this.MyPrintIcon); printPreviewDialog.Document = printDocument; printPreviewDialog.ShowDialog(); }
} //private void pD1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) private bool SetupThePrinting(string Titulo) { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } pD1.DocumentName = Titulo; pD1.PrinterSettings = MyPrintDialog.PrinterSettings; pD1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; pD1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); if (MessageBox.Show("¿Quieres el listado centrado en la página?", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(dGv1, pD1, true, true, Titulo, new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } else { MyDataGridViewPrinter = new DataGridViewPrinter(dGv1, pD1, false, true, Titulo, new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } return(true); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; //if (MyPrintDialog.ShowDialog() != DialogResult.OK) // return false; MyPrintDocument.DocumentName = lblNombreGrupo.Text; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyPrintDocument.DefaultPageSettings.Landscape = true; MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, MyPrintDocument, false, "Captura de Calificaciones" + lblNombreGrupo.Text + "\n Materia: " + materias.ElementAt(cmbMaterias.SelectedIndex).nombre + "\n \n Maestro:__________________________________________ \n\n", new Font("Tahoma", 14, FontStyle.Bold, GraphicsUnit.Point), Color.Black, "FOOTER GIGANTE PARA VER QUE PASA CUANDO QUIERO IMPRIMIR UN SUPPER FOOTER GIGANTESCO", new Font("Tahoma", 14, FontStyle.Bold, GraphicsUnit.Point), Color.Black, false); return(true); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } pd = new System.Drawing.Printing.PrintDocument(); pd.DocumentName = "Сверка фонда"; //pd.PrinterSettings = MyPrintDialog.PrinterSettings; pd.DefaultPageSettings = pd.PrinterSettings.DefaultPageSettings; pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20); pd.DefaultPageSettings.Landscape = true; pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); prin = new DataGridViewPrinter(dgw2, pd, true, false, string.Empty, new Font("Tahoma", 18), Color.Black, false); return(true); }
private bool SetupThePrinting() { //PrintDialog MyPrintDialog = new PrintDialog(); printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Resumen de cuenta"; MyPrintDocument.PrinterSettings = printDialog1.PrinterSettings; MyPrintDocument.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(12, 12, 20, 20); MyDataGridViewPrinter = new DataGridViewPrinter(DG_Cuenta, MyPrintDocument, false, true, "Resumen de cuenta de " + Txt_NombreTercero.Text + " (" + DateTime.Now.ToString("dd/MM/yy") + ")", new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Documents Status Report"; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); if (MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(dgvDocuments, MyPrintDocument, true, true, "Documents Status Report", new System.Drawing.Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } else { MyDataGridViewPrinter = new DataGridViewPrinter(dgvDocuments, MyPrintDocument, true, true, "Documents Status Report", new System.Drawing.Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } return(true); }
private bool SetupThePrinting() { //PrintDialog MyPrintDialog = new PrintDialog(); printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Lista de artículos"; MyPrintDocument.PrinterSettings = printDialog1.PrinterSettings; MyPrintDocument.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(12, 12, 20, 100); //DG_Datos.Columns.RemoveAt(2); //DG_Datos.Columns.RemoveAt(2); //DG_Datos.Columns.RemoveAt(3); MyDataGridViewPrinter = new DataGridViewPrinter(DG_Datos, MyPrintDocument, false, true, "Lista de artículos del " + DateTime.Now.ToLongDateString(), new Font("Arial", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
/// <summary> /// Method to set up the printing /// </summary> /// <param name="isPrint">isPrint value</param> /// <returns>true or false</returns> private bool SetupPrinting(bool isPrint) { PrintDialog printDialog = new PrintDialog(); printDialog.AllowCurrentPage = false; printDialog.AllowPrintToFile = false; printDialog.AllowSelection = false; printDialog.AllowSomePages = false; printDialog.PrintToFile = false; printDialog.ShowHelp = false; printDialog.ShowNetwork = false; if (isPrint) { if (printDialog.ShowDialog() != DialogResult.OK) { return(false); } } this.PrintReport.DocumentName = "MembersReport"; this.PrintReport.PrinterSettings = printDialog.PrinterSettings; this.PrintReport.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; this.PrintReport.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); this.dataGridViewPrinter = new DataGridViewPrinter(dataGridViewMembers, PrintReport, true, true, Resources.Report_Header, new Font("Tahoma", 13, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
//打印报表 private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } string title; MyPrintDocument.DocumentName = unitName; title = MyPrintDocument.DocumentName; //标题 MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyDataGridViewPrinter = new DataGridViewPrinter(RecordGrid, MyPrintDocument, true, true, title, new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) return false; MyPrintDocument.DocumentName = this.TabText; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); string strTitle = this.TabText+"(" + this.tbxStartDate.Text + "至" + this.tbxEndDate.Text+")"; MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, MyPrintDocument, true, true, strTitle, new Font("Tahoma", 12, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return true; }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; //if (MyPrintDialog.ShowDialog() != DialogResult.OK) // return false; MyPrintDocument.DocumentName = "HistorialPagos" + alumno; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyPrintDocument.DefaultPageSettings.Landscape = true; MyDataGridViewPrinter = new DataGridViewPrinter(dataGridViewPagos, MyPrintDocument, false, "Alumno: " + lblNombreAlumno.Text + "\n Concepto: " + concepto, new Font("Arial", 14, FontStyle.Bold, GraphicsUnit.Point), Color.Black, "Total pagado: " + auxTotal + " \nPendiente: " + auxPendiente, new Font("Arial", 12, FontStyle.Bold, GraphicsUnit.Point), Color.Black, false); return(true); }
private bool SetupThePrinting() { string sql3 = "select * from tbl_terminalLocation where Shopid = '" + UserInfo.Shopid + "'"; DataAccess.ExecuteSQL(sql3); DataTable dt1 = DataAccess.GetDataTable(sql3); DateTime dt = DateTime.Now; string printdate = dt.ToString("MMMM dd, yyyy hh:mm:ss tt"); string Companyname = dt1.Rows[0].ItemArray[1].ToString(); string branchname = dt1.Rows[0].ItemArray[2].ToString(); string Location = dt1.Rows[0].ItemArray[3].ToString(); string phone = dt1.Rows[0].ItemArray[4].ToString(); string email = dt1.Rows[0].ItemArray[5].ToString(); string web = dt1.Rows[0].ItemArray[6].ToString(); string Header = Companyname + "\n" + Location + "." + "\n" + email + "\n" + branchname + " ph: " + phone + "\n" + printdate + "\n"; PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } printDocument1.DocumentName = "Sales Report"; printDocument1.PrinterSettings = MyPrintDialog.PrinterSettings; printDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); //if (MessageBox.Show("Do you want the report to be centered on the page", // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, // MessageBoxIcon.Question) == DialogResult.Yes) MyDataGridViewPrinter = new DataGridViewPrinter(datagrdReportDetails, printDocument1, true, true, Header + " Sales Report \n", new Font("Baskerville Old Face", 13, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); // tosend = "<html><table>" + tosend + "</table></html>"; // mail.IsBodyHtml = true; //mail.Body = tosend; //else // MyDataGridViewPrinter = new DataGridViewPrinter(datagrdReportDetails, // printDocument1, false, true, Header + " Sales Report \n", new Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); return(true); }
private void navPrint_Click(object sender, EventArgs e) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); TeamPrintDialogForm curTeamPrintDialog = new TeamPrintDialogForm(); if (curTeamPrintDialog.ShowDialog() == DialogResult.OK) { String curPrintReport = curTeamPrintDialog.ReportName; bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 14, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if (curPrintDialog.ShowDialog() == DialogResult.OK) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins(50, 50, 75, 75); myPrintDoc.DefaultPageSettings.Landscape = false; if (curPrintReport.Equals("TeamResults")) { myPrintDataGrid = new DataGridViewPrinter(PrintDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging); } else { printTitle += " - Skier List"; myPrintDataGrid = new DataGridViewPrinter(scoreSummaryDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging); } myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } } }
private bool SetupThePrinting() { string sql3 = "select * from storeconfig"; DataAccess.ExecuteSQL(sql3); DataTable dt1 = DataAccess.GetDataTable(sql3); DateTime dt = DateTime.Now; string s = dt.ToString("MMMM dd, yyyy hh:mm:ss tt"); string sd = dt1.Rows[0].ItemArray[1].ToString() + "\n" + dt1.Rows[0].ItemArray[2].ToString() + "." + "\n" + dt1.Rows[0].ItemArray[3].ToString() + "\n" + s + "\n"; PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } printDocument1.DocumentName = "Credit Report"; printDocument1.PrinterSettings = MyPrintDialog.PrinterSettings; printDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); if (MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(dtGrdvCustomerDetails, printDocument1, true, true, sd + " Store Credit Report \n", new Font("Baskerville Old Face", 13, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); } // tosend = "<html><table>" + tosend + "</table></html>"; // mail.IsBodyHtml = true; //mail.Body = tosend; else { MyDataGridViewPrinter = new DataGridViewPrinter(dtGrdvCustomerDetails, printDocument1, false, true, sd + " Store Credit Report \n", new Font("Times New Roman", 14, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); } return(true); }
private bool SetupThePrinting() { string Text; printDialog1.AllowCurrentPage = false; printDialog1.AllowPrintToFile = false; printDialog1.AllowSelection = false; printDialog1.AllowSomePages = false; printDialog1.PrintToFile = false; printDialog1.ShowHelp = false; printDialog1.ShowNetwork = false; if (printDialog1.ShowDialog() != DialogResult.OK) { return(false); } printDocument1.DocumentName = "Client Statement"; printDocument1.PrinterSettings = printDialog1.PrinterSettings; printDocument1.DefaultPageSettings = printDialog1.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); Text = txtCBName.Text + Environment.NewLine + txtStateAccType.Text + Environment.NewLine + "" + Environment.NewLine + txtAddress.Text + Environment.NewLine + "" + Environment.NewLine + "From date: " + Environment.NewLine + "To date: " + Environment.NewLine + "Print date: " + DateTime.Today.ToShortDateString() + Environment.NewLine + "" + Environment.NewLine + "Account number: " + txtStateAccNumber.Text + " " + txtStateAccType.Text + Environment.NewLine + "" + Environment.NewLine + ""; //if (MessageBox.Show("Do you want the report to be centered on the page", // "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, // MessageBoxIcon.Question) == DialogResult.Yes) // MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, // printDocument1, true, true, "Statement", new Font("Tahoma", 18, // FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); //else MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, printDocument1, false, true, Text, new Font("Tahoma", 8, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
//打印预览 private void PrintView_ToolStripMenuItem_Click(object sender, EventArgs e) { DataGridView dgv = GetDataGridView(); if (dgv != null) { MyDataGridViewPrinter = new DataGridViewPrinter(dgv, MyPrintDocument, true, true, dgv.Name, new Font("SimSun", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); this.printPreviewDialog1.Document = MyPrintDocument; if (this.printPreviewDialog1.ShowDialog() == DialogResult.Cancel) { this.PRINT = false; } } }
private void 打印Button_Click(object sender, EventArgs e) {//打印收入统计信息 string title = this.MyCommunity + "收入统计信息表"; printDocument.DocumentName = title; printDocument.PrinterSettings = printDialog.PrinterSettings; printDocument.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; printDocument.DefaultPageSettings.Margins = new Margins(10, 10, 20, 20); print = new DataGridViewPrinter(this.收入统计报表DataGridView, printDocument, title); PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.WindowState = FormWindowState.Maximized; printPreviewDialog.Icon = new Icon(this.MyPrintIcon); printPreviewDialog.Document = printDocument; printPreviewDialog.ShowDialog(); }
private void toolStripButton1_Click(object sender, EventArgs e) { if (printer.ShowDialog() != DialogResult.OK) { return; } PrintDocument MyPrintDocument = new PrintDocument(); MyPrintDocument.DocumentName = "Програмное обеспечение"; MyPrintDocument.PrinterSettings = printer.PrinterSettings; MyPrintDocument.DefaultPageSettings = printer.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyPrintDocument.PrintPage += MyPrintDocument_PrintPage; MyDataGridViewPrinter = new DataGridViewPrinter(grid, MyPrintDocument, true, true, "Програмное обеспечение", new Font("Tahoma", 12, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); MyPrintDocument.Print(); }
private void 打印ToolStripButton_Click(object sender, EventArgs e) {//打印楼栋信息 string title = this.MyCommunity + "楼栋信息表"; //if (printDialog.ShowDialog() != DialogResult.OK) // return; printDocument.DocumentName = title; printDocument.PrinterSettings = printDialog.PrinterSettings; printDocument.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; printDocument.DefaultPageSettings.Margins = new Margins(10, 10, 20, 20); print = new DataGridViewPrinter(this.楼栋信息DataGridView, printDocument, title); PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.WindowState = FormWindowState.Maximized; printPreviewDialog.Icon = new Icon(this.MyPrintIcon); printPreviewDialog.Document = printDocument; printPreviewDialog.ShowDialog(); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Customers Report"; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); if (MessageBox.Show("출력 문서를 중앙에 정렬 하시겠습니까?", "질문", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, MyPrintDocument, true, true, Title, new Font("맑은 고딕", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } else { MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, MyPrintDocument, false, true, Title, new Font("맑은 고딕", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); } return(true); }
private void btn_Print_Click(object sender, EventArgs e) { DataGridViewPrinter DGVP; switch (tabControl1.SelectedIndex) { case 0: DGVP = new DataGridViewPrinter(this.DataGrid_PersonSend, "人员发送报警统计", "", "", "", "", false, this.DataGrid_PersonSend.ColumnCount); break; case 1: DGVP = new DataGridViewPrinter(this.DataGrid_Machine, "故障基站报警统计", "", "", "", "", false, this.DataGrid_Machine.ColumnCount); break; case 2: DGVP = new DataGridViewPrinter(this.DataGrid_Power, "卡片缺电报警统计", "", "", "", "", false, this.DataGrid_Power.ColumnCount); break; case 3: switch (MessageBox.Show("您是要打印《超员报警统计》还《超时报警统计》?\n\n 是 - 超员报警统计\n\n 否 - 超时报警统计", "数据表打印", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question)) { case DialogResult.Yes: DGVP = new DataGridViewPrinter(this.DataGrid_AlarmMaxPerson, "超员报警统计", "", "", "", "", false, this.DataGrid_AlarmMaxPerson.ColumnCount); break; case DialogResult.No: DGVP = new DataGridViewPrinter(this.DataGrid_AlarmMaxHour, "超时报警统计", "", "", "", "", false, this.DataGrid_AlarmMaxHour.ColumnCount); break; default: return; } break; default: DGVP = new DataGridViewPrinter(this.DataGrid_NoCard, "无卡人员进入报警统计", "", "", "", "", false, this.DataGrid_NoCard.ColumnCount); break; } DGVP.Print(); }
private void navPrint_Click(object sender, EventArgs e) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); bool CenterOnPage = false; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 14, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if (curPrintDialog.ShowDialog() == DialogResult.OK) { String printTitle = Properties.Settings.Default.Mdi_Title + " - " + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins(25, 25, 25, 25); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDoc.DefaultPageSettings.Landscape = false; myPrintDataGrid = new DataGridViewPrinter(tourBoatUseDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }
private bool SetupThePrinting() { string baslik = "*" + ilktarih + " İLE " + sontarih + " ARASI '" + ogrencinum + "' NUMARALI '" + ogrenciadisoyadi + "' YEMEĞE GELİŞ LİSTESİ"; PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = true; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; //if (MyPrintDialog.ShowDialog() != DialogResult.OK) // return false; printDocument1.DocumentName = "HAREKET KAYITLARI"; printDocument1.PrinterSettings = MyPrintDialog.PrinterSettings; printDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(40, 40, 80, 40); if (MessageBox.Show("Raporu sayfaya ortalamak ister misiniz?", "Rapor Ortalaması", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, printDocument1, true, true, "*" + ilktarih + " İLE " + sontarih + " ARASI '" + ogrencinum + "' NUMARALI '" + ogrenciadisoyadi + "' YEMEĞE GELİŞ LİSTESİ", new Font("Tahoma", 12, FontStyle.Bold, GraphicsUnit.Point), System.Drawing.Color.Black, true); } else { MyDataGridViewPrinter = new DataGridViewPrinter(dataGridView1, printDocument1, false, true, baslik, new Font("Tahoma", 14, FontStyle.Bold, GraphicsUnit.Point), System.Drawing.Color.Black, true); } return(true); }
private bool SetupThePrinting() //TODO: Implement ODprintout pattern { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; MyPrintDialog.UseEXDialog = true; if (MyPrintDialog.ShowDialog() != DialogResult.OK) { return(false); } MyPrintDocument.DocumentName = "Patient Eligibility Response"; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyDataGridViewPrinter = new DataGridViewPrinter(this.dataGridView1, MyPrintDocument, true, true, this.LblPatientName.Text, new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return(true); }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) return false; printDocument1.DocumentName = "Customers Report"; printDocument1.PrinterSettings = MyPrintDialog.PrinterSettings; printDocument1.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; printDocument1.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); if (MessageBox.Show("Do you want the report to be centered on the page", "InvoiceManager - Center on Page", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, printDocument1, true, true, "Отчет", new Font("Tahoma", 12, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); else MyDataGridViewPrinter = new DataGridViewPrinter(MyDataGridView, printDocument1, false, true, "Отчет", new Font("Tahoma", 12, FontStyle.Regular, GraphicsUnit.Point), Color.Black, true); return true; }
private void navPrint_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); //PageSetupDialog bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 14, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); try { curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = true; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins( 25, 25, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( scoreSummaryDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDataGrid.SubtitleList(); StringRowPrinter mySubtitle; StringFormat SubtitleStringFormat = new StringFormat(); SubtitleStringFormat.Trimming = StringTrimming.Word; SubtitleStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormat.Alignment = StringAlignment.Center; if ( plcmtDivButton.Checked ) { mySubtitle = new StringRowPrinter( SlalomLabel.Text, 140, 0, 302, SlalomLabel.Size.Height, SlalomLabel.ForeColor, SlalomLabel.BackColor, SlalomLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; } else { mySubtitle = new StringRowPrinter( SlalomLabel.Text, 175, 0, 302, SlalomLabel.Size.Height, SlalomLabel.ForeColor, SlalomLabel.BackColor, SlalomLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; } myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } } catch ( Exception ex ) { MessageBox.Show( "Exception encountered during print request" + "\n\nException: " + ex.Message ); } }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; MyPrintDialog.UseEXDialog=true; if(MyPrintDialog.ShowDialog() != DialogResult.OK){ return false; } MyPrintDocument.DocumentName = "Patient Eligibility Response"; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40,40,40,40); MyDataGridViewPrinter = new DataGridViewPrinter(this.dataGridView1,MyPrintDocument,true,true,this.LblPatientName.Text,new Font("Tahoma",18,FontStyle.Bold,GraphicsUnit.Point),Color.Black,true); return true; }
private void navPrint_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font( "Arial Narrow", 12, FontStyle.Bold ); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins( 50, 50, 50, 50 ); myPrintDataGrid = new DataGridViewPrinter( TourDivDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }
private void navPrint_Click(object sender, EventArgs e) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); //Font saveShowDefaultCellStyle = PrintDataGridView.DefaultCellStyle.Font; //PrintDataGridView.DefaultCellStyle.Font = new Font("Tahoma", 12, FontStyle.Regular); bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 12, FontStyle.Bold); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if(curPrintDialog.ShowDialog() == DialogResult.OK) { RankingScore.HeaderText = "NRS"; String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins( 30, 30, 30, 30 ); myPrintDataGrid = new DataGridViewPrinter( PrintDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); if (printHeaderNote.Text.Length > 0) { myPrintDataGrid.SubtitleList(); Font fontPrintSubTitle = new Font( "Arial", 12, FontStyle.Bold ); StringFormat SubtitleStringFormat = new StringFormat(); SubtitleStringFormat.Trimming = StringTrimming.Word; SubtitleStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormat.Alignment = StringAlignment.Center; StringRowPrinter curSubtitle = new StringRowPrinter( printHeaderNote.Text, 0, 0, 750, 25 , Color.DarkBlue, Color.LightGray, fontPrintSubTitle, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = curSubtitle; } myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); RankingScore.HeaderText = "Ranking Score"; } }
private void navPrint_Click( object sender, EventArgs e ) { int curCount = 0; String curTourPlcmtOrg = "tour"; foreach(DataGridViewRow curRow in EventRegDataGridView.Rows) { if (( (String)curRow.Cells["EventGroup"].Value ).Equals( "HH1" )) { curCount++; } } if (curCount > 0) { if (curCount > 2) { curTourPlcmtOrg = "Div"; } printHeadToHeadAwards( curTourPlcmtOrg ); return; } PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 12, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if (curPrintDialog.ShowDialog() == DialogResult.OK) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins(50, 50, 50, 50); myPrintDataGrid = new DataGridViewPrinter(PrintDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) return false; MyPrintDocument.DocumentName = "Schedule Report"; MyPrintDocument.PrinterSettings = MyPrintDialog.PrinterSettings; MyPrintDocument.DefaultPageSettings = MyPrintDialog.PrinterSettings.DefaultPageSettings; MyPrintDocument.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); MyPrintDocument.DefaultPageSettings.Landscape = true; MyDataGridViewPrinter = new DataGridViewPrinter(dgvSchedule, MyPrintDocument, false, true, "ScheduleViewer", new Font("Tahoma", 18, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); foreach (int i in widths) { Font tmpFont = dgvSchedule.ColumnHeadersDefaultCellStyle.Font; //System.Drawing.SizeConverter MyDataGridViewPrinter.ColumnsWidth.Add(i * tmpFont.Size / (float)8.75); } return true; }
/// <summary> /// Initializes the print dialog. /// </summary> /// <returns>True if initialization succedded.</returns> private bool initPrintSettings() { if (!recordsSelectedForPrint()) return false; PrintDialog printDialog = new PrintDialog(); printDialog.AllowCurrentPage = false; printDialog.AllowPrintToFile = false; printDialog.AllowSelection = false; printDialog.AllowSomePages = false; printDialog.PrintToFile = false; printDialog.ShowHelp = false; printDialog.ShowNetwork = false; if (printDialog.ShowDialog() != DialogResult.OK) return false; _printDoc.DocumentName = "UnclaimedFundsList"; _printDoc.PrinterSettings = printDialog.PrinterSettings; _printDoc.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; _printDoc.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); _printDataGridView = DataGridViewUtilities.CopyDataGridViewPrintSelected(dataGridViewMatch); _printDataGridView.Refresh(); _gridPrinter = new DataGridViewPrinter(_printDataGridView, _printDoc, "TIM HOWARD'S LIST", true); return true; }
private void btnPrintPreview_Click(object sender, EventArgs e) { if(recordsSelectedForPrint()) { var printPreview = new PrintPreviewDialog(); //Disable the print button. Printing through the preview does not work. ((ToolStripButton)((ToolStrip)printPreview.Controls[1]).Items[0]).Enabled = false; printPreview.Document = _printDoc; ((Form)printPreview).WindowState = FormWindowState.Maximized; _printDataGridView = DataGridViewUtilities.CopyDataGridViewPrintSelected(dataGridViewMatch); _printDataGridView.Refresh(); _gridPrinter = new DataGridViewPrinter(_printDataGridView, _printDoc, "TIM HOWARD'S LIST", true); printPreview.ShowDialog(); } }
private void navPrint_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); Font saveShowDefaultCellStyle = scoreSummaryDataGridView.DefaultCellStyle.Font; scoreSummaryDataGridView.DefaultCellStyle.Font = new Font( "Tahoma", 10, FontStyle.Regular ); bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 14, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins( 25, 25, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( scoreSummaryDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDataGrid.SubtitleList(); StringRowPrinter mySubtitle; StringFormat SubtitleStringFormat = new StringFormat(); SubtitleStringFormat.Trimming = StringTrimming.Word; SubtitleStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormat.Alignment = StringAlignment.Center; int curLabelLocSlalom = 0, curLabelLocTrick = 0, curLabelLocJump = 0, curLabelLocOverall = 0; if (myTourRules.ToLower().Equals( "ncwsa" )) { curLabelLocSlalom = 295; curLabelLocTrick = 572; curLabelLocJump = 737; curLabelLocOverall = 887; } else { if (EventGroup.Visible) { curLabelLocSlalom = 244; curLabelLocTrick = 550; curLabelLocJump = 729; curLabelLocOverall = 897; } else { curLabelLocSlalom = 204; curLabelLocTrick = 517; curLabelLocJump = 697; curLabelLocOverall = 862; } } mySubtitle = new StringRowPrinter( SlalomLabel.Text, curLabelLocSlalom, 0, Convert.ToInt32( SlalomLabel.Width * .8 ), SlalomLabel.Size.Height, SlalomLabel.ForeColor, SlalomLabel.BackColor, SlalomLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( TrickLabel.Text, curLabelLocTrick, 0, Convert.ToInt32( TrickLabel.Width * .65 ), TrickLabel.Size.Height, TrickLabel.ForeColor, TrickLabel.BackColor, TrickLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( JumpLabel.Text, curLabelLocJump, 0, Convert.ToInt32( JumpLabel.Width * .65 ), JumpLabel.Size.Height, JumpLabel.ForeColor, JumpLabel.BackColor, JumpLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( OverallLabel.Text, curLabelLocOverall, 0, OverallLabel.Size.Width, OverallLabel.Size.Height, OverallLabel.ForeColor, OverallLabel.BackColor, OverallLabel.Font, SubtitleStringFormat ); myPrintDataGrid.SubtitleRow = mySubtitle; myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } scoreSummaryDataGridView.DefaultCellStyle.Font = saveShowDefaultCellStyle; }
/// <summary> /// Method to set up the printing /// </summary> /// <param name="isPrint">isPrint value</param> /// <returns>true or false</returns> private bool SetupPrinting(bool isPrint) { PrintDialog printDialog = new PrintDialog(); printDialog.AllowCurrentPage = false; printDialog.AllowPrintToFile = false; printDialog.AllowSelection = false; printDialog.AllowSomePages = false; printDialog.PrintToFile = false; printDialog.ShowHelp = false; printDialog.ShowNetwork = false; if (isPrint) { if (printDialog.ShowDialog() != DialogResult.OK) { return false; } } this.PrintReport.DocumentName = "MembersReport"; this.PrintReport.PrinterSettings = printDialog.PrinterSettings; this.PrintReport.DefaultPageSettings = printDialog.PrinterSettings.DefaultPageSettings; this.PrintReport.DefaultPageSettings.Margins = new Margins(40, 40, 40, 40); this.dataGridViewPrinter = new DataGridViewPrinter(dataGridViewMembers, PrintReport, true, true, Resources.Report_Header, new Font("Tahoma", 13, FontStyle.Bold, GraphicsUnit.Point), Color.Black, true); return true; }
private void navPrint_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); loadPrintTeamSkierList(); bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font( "Arial Narrow", 14, FontStyle.Bold ); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + " - Team List"; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins( 25, 25, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter(PrintTeamDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }
private bool SetupThePrinting() { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) return false; pd = new System.Drawing.Printing.PrintDocument(); pd.DocumentName = "������ �����"; //pd.PrinterSettings = MyPrintDialog.PrinterSettings; pd.DefaultPageSettings = pd.PrinterSettings.DefaultPageSettings; pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20); pd.DefaultPageSettings.Landscape = true; pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); prin = new DataGridViewPrinter(dgw2, pd, true, false, string.Empty, new Font("Tahoma", 18), Color.Black, false); return true; }
private void navPrint_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); Font saveShowDefaultCellStyle = TeamSummaryDataGridView.DefaultCellStyle.Font; TeamSummaryDataGridView.DefaultCellStyle.Font = new Font( "Tahoma", 12, FontStyle.Regular ); TeamSummaryDataGridView.RowTemplate.Height = 34; bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font( "Arial Narrow", 14, FontStyle.Bold ); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String curReportTitle = this.Text; String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + curReportTitle; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = curReportTitle + "-Team"; myPrintDoc.DefaultPageSettings.Margins = new Margins( 25, 25, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( TeamSummaryDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = curReportTitle + "-Detail"; myPrintDoc.DefaultPageSettings.Margins = new Margins( 25, 25, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( PrintDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } TeamSummaryDataGridView.DefaultCellStyle.Font = saveShowDefaultCellStyle; TeamSummaryDataGridView.RowTemplate.Height = 28; }
public void PrintDataGrid( Control inControl, int inPageAdjX, int inPageAdjY ) { DataGridView curControl = (System.Windows.Forms.DataGridView)inControl; bool curCenterOnPage = false; int curPageHeight = myPageHeight; int curPageWidth = myPageWidth; int curTopMargin = curControl.Location.Y + inPageAdjY; int curBottomMargin = myBottomMargin; int curLeftMargin = myLeftMargin; int curRightMargin = myRightMargin; /* DataGridViewPrinter myPrintDataGrid = new DataGridViewPrinter( curControl, curCenterOnPage, curPageHeight, curPageWidth, curTopMargin, curBottomMargin, curLeftMargin, curRightMargin ); */ DataGridViewPrinter myPrintDataGrid = new DataGridViewPrinter( curControl, myPrintDoc, curCenterOnPage, curPageHeight, curPageWidth, curTopMargin, curBottomMargin, curLeftMargin, curRightMargin ); myPrintDataGrid.DrawDataGridView( myGraphicControl ); }
private void navPrint_Click(object sender, EventArgs e) { if (h2hScoreButton.Checked) { if (mySummaryDataTable.Rows.Count > 0) { printHeadToHeadAwards(); return; } else { return; } } PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); Font saveShowDefaultCellStyle = scoreSummaryDataGridView.DefaultCellStyle.Font; if (myTourRules.ToLower().Equals( "ncwsa" )) { scoreSummaryDataGridView.DefaultCellStyle.Font = new Font( "Tahoma", 12, FontStyle.Regular ); } else { scoreSummaryDataGridView.DefaultCellStyle.Font = new Font( "Tahoma", 11, FontStyle.Regular ); } bool CenterOnPage = true; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font("Arial Narrow", 14, FontStyle.Bold); Font fontPrintFooter = new Font("Times New Roman", 10); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = true; curPrintDialog.AllowSelection = false; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; if (curPrintDialog.ShowDialog() == DialogResult.OK) { String printTitle = Properties.Settings.Default.Mdi_Title + "\n Sanction " + mySanctionNum + " held on " + myTourRow["EventDates"].ToString() + "\n" + this.Text ; myPrintDoc = new PrintDocument(); myPrintDoc.DocumentName = this.Text; myPrintDoc.DefaultPageSettings.Margins = new Margins(25, 25, 25, 25); myPrintDoc.DefaultPageSettings.Landscape = false; myPrintDataGrid = new DataGridViewPrinter(scoreSummaryDataGridView, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging); myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler(printDoc_PrintPage); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } scoreSummaryDataGridView.DefaultCellStyle.Font = saveShowDefaultCellStyle; }
private void navPrintResults_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); DataGridView[] myViewList = new DataGridView[1]; myViewList[0] = slalomRecapDataGridView; bool CenterOnPage = false; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font( "Arial Narrow", 14, FontStyle.Bold ); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + " - " + this.Text; myPrintDoc = new PrintDocument(); String curDocName = ""; String curAgeGroup = (String)TourEventRegDataGridView.CurrentRow.Cells["AgeGroup"].Value; String curSkierName = (String)TourEventRegDataGridView.CurrentRow.Cells["SkierName"].Value; String[] curNameParts = curSkierName.Split( ',' ); if ( curNameParts.Length > 1 ) { curDocName = curNameParts[1].Trim() + curNameParts[0].Trim() + "_" + curAgeGroup; } else if ( curNameParts.Length == 1 ) { curDocName = curNameParts[1].Trim() + curNameParts[0].Trim() + "_" + curAgeGroup; } else { curDocName = "Unknown"; } curSkierName += " " + curAgeGroup; myPrintDoc.DocumentName = curDocName; myPrintDoc.DefaultPageSettings.Margins = new Margins( 125, 125, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( myViewList, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); //Build titles for each data grid view myPrintDataGrid.GridViewTitleList(); StringRowPrinter myGridTitle; StringFormat GridTitleStringFormat = new StringFormat(); GridTitleStringFormat.Trimming = StringTrimming.Word; GridTitleStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; GridTitleStringFormat.Alignment = StringAlignment.Near; myGridTitle = new StringRowPrinter( "Slalom Pass Round " + roundSelect.RoundValue, 0, 20, 325, fontPrintTitle.Height, Color.DarkBlue, Color.White, fontPrintTitle, GridTitleStringFormat ); myPrintDataGrid.GridViewTitleRow = myGridTitle; //Build report page subtitles myPrintDataGrid.SubtitleList(); StringRowPrinter mySubtitle; StringFormat SubtitleStringFormatLeft = new StringFormat(); SubtitleStringFormatLeft.Trimming = StringTrimming.Word; SubtitleStringFormatLeft.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormatLeft.Alignment = StringAlignment.Near; StringFormat SubtitleStringFormatCenter = new StringFormat(); SubtitleStringFormatCenter.Trimming = StringTrimming.Word; SubtitleStringFormatCenter.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormatCenter.Alignment = StringAlignment.Center; mySubtitle = new StringRowPrinter( curSkierName, 0, 0, 325, fontPrintTitle.Height, Color.DarkBlue, Color.White, fontPrintTitle, SubtitleStringFormatLeft ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( scoreLabel.Text, 0, 25, 50, scoreLabel.Size.Height, Color.Black, Color.White, scoreLabel.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( scoreTextBox.Text, 0, 40, 50, scoreTextBox.Size.Height, Color.Black, Color.White, scoreTextBox.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( nopsScoreLabel.Text, 170, 25, 50, nopsScoreLabel.Size.Height, Color.Black, Color.White, nopsScoreLabel.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( nopsScoreTextBox.Text, 170, 40, 55, nopsScoreTextBox.Size.Height, Color.Black, Color.White, nopsScoreTextBox.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }
private void button12_Click(object sender, EventArgs e) { if (Statistics.Columns.Count == 3) { PrintDialog MyPrintDialog = new PrintDialog(); MyPrintDialog.AllowCurrentPage = false; MyPrintDialog.AllowPrintToFile = false; MyPrintDialog.AllowSelection = false; MyPrintDialog.AllowSomePages = false; MyPrintDialog.PrintToFile = false; MyPrintDialog.ShowHelp = false; MyPrintDialog.ShowNetwork = false; if (MyPrintDialog.ShowDialog() != DialogResult.OK) return; pd = new System.Drawing.Printing.PrintDocument(); pd.DocumentName = "������ �����"; //pd.PrinterSettings = MyPrintDialog.PrinterSettings; pd.DefaultPageSettings = pd.PrinterSettings.DefaultPageSettings; pd.DefaultPageSettings.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20); pd.DefaultPageSettings.Landscape = false; pd.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(pd_PrintPage); string tit = "���������� ����������/��������� \n�� ������ � "+MyDateSpan.start.ToShortDateString() + " �� " + MyDateSpan.end.ToShortDateString() + "."; prin = new DataGridViewPrinter(Statistics, pd, true, true, tit, new Font("Tahoma", 18), Color.Black, false); pd.Print(); } else { //����������� ���������� ListSortDirection SO = ListSortDirection.Ascending; dgw2 = new DataGridView(); //DataGridViewRow[] arr = new DataGridViewRow[Statistics.SelectedRows.Count]; DataGridViewColumn[] arr1 = new DataGridViewColumn[Statistics.Columns.Count]; //Statistics.SelectedRows.CopyTo(arr, 0); Statistics.Columns.CopyTo(arr1, 0); dgw2.AutoGenerateColumns = false; dgw2.Columns.Clear(); dgw2.Font = new Font("Times New Roman", 10); //dgw2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; //dgw2.RowTemplate.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True; //dgw2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgw2.AllowUserToAddRows = false; //dgw2.Columns.AddRange(arr1); foreach (DataGridViewColumn col in arr1) { //dgw2.Columns.Add((DataGridViewColumn)col.Clone()); dgw2.Columns.Add("",""); } int i = 0; for (int ri = 0; ri < Statistics.Rows.Count; ri++) { dgw2.Rows.Add();// (DataGridViewRow)Statistics.SelectedRows[ri].Clone(); DataGridViewRow clonedRow = dgw2.Rows[i]; for (Int32 index = 0; index < Statistics.Rows[ri].Cells.Count; index++) { dgw2.Rows[i].Cells[index].Value = Statistics.Rows[ri].Cells[index].Value; } //dgw2.Rows.Add(clonedRow); i++; } dgw2.AutoSize = false; dgw2.RowTemplate.DefaultCellStyle.WrapMode = System.Windows.Forms.DataGridViewTriState.True; dgw2.ColumnHeadersDefaultCellStyle.WrapMode = DataGridViewTriState.True; dgw2.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; dgw2.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells; //Statistics.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None; dgw2.Columns[0].Width = 35; dgw2.Columns[1].Width = 470; dgw2.Columns[2].Width = 215; dgw2.Columns[2].Visible = true; dgw2.Columns[3].Width = 70; dgw2.Columns[4].Visible = false; dgw2.Columns[5].Visible = false; dgw2.Columns[6].Visible = false; dgw2.Columns[7].Width = 70; dgw2.Columns[8].Width = 100; dgw2.Columns[9].Visible = false; dgw2.Columns[10].Width = 70; dgw2.Columns[11].Width = 70; dgw2.Columns[1].HeaderText = "��������"; dgw2.Columns[2].HeaderText = "�����"; dgw2.Columns[3].HeaderText = "���. �����"; dgw2.Columns[4].HeaderText = "��������������"; dgw2.Columns[7].HeaderText = "����� ������"; dgw2.Columns[8].HeaderText = "���"; dgw2.Columns[10].HeaderText = "���� ������"; dgw2.Columns[10].ValueType = typeof(DateTime); dgw2.Columns[11].HeaderText = "���� ��������"; if (Statistics.SortedColumn != null) { if (Statistics.Columns[Statistics.SortedColumn.Index].HeaderCell.SortGlyphDirection == System.Windows.Forms.SortOrder.Ascending) { SO = ListSortDirection.Ascending; } if (Statistics.Columns[Statistics.SortedColumn.Index].HeaderCell.SortGlyphDirection == System.Windows.Forms.SortOrder.Descending) { SO = ListSortDirection.Descending; } dgw2.Sort(dgw2.Columns[Statistics.SortedColumn.Index], SO); } //dgw2 autoinc(dgw2); if (SetupThePrinting()) pd.Print(); } }