private void printButton_Click(object sender, EventArgs e) { try { streamToPrint = new StreamReader("C:\\MyFile.txt"); try { //var pd = new PrintDocument(); //pd.PrintPage += PdPrintPage; //pd.Print(); var gridControlBase = new GridControlBase(); var gpd = new GridPrintDocument(gridControlBase); gpd.PrintPage += PdPrintPage; gpd.Print(); } finally { streamToPrint.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override void InvokeAction(object sender, EventArgs e) { GridControlBase grid = ActiveGrid; if (grid != null) { try { GridPrintDocument pd = new GridPrintDocument(grid, true); //Assumes the default printer if (PrinterSettings.storedPageSettings != null) { pd.DefaultPageSettings = PrinterSettings.storedPageSettings; } PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = pd; dlg.ShowDialog(); } catch (Exception ex) { MessageBox.Show("An error occurred attempting to preview the file to print - " + ex.Message); } } }
private void sendToPrinterToolStripMenuItem_Click(object sender, EventArgs e) { // dataGridView1 is the DataGridView to print GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); doc.DocumentName = "Preview Test"; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; // calc factor for fit grid in one page float scale = doc.CalcScaleForFit(); doc.ScaleFactor = scale; // show the grid again printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "PrintPreviewDialog1"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
private void button4_Click(object sender, EventArgs e) { GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); doc.DocumentName = "Preview Test"; doc.DefaultPageSettings.Landscape = true; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); float scale = doc.CalcScaleForFit(); doc.ScaleFactor = scale; printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "PrintPreviewDialog1"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
private void button1_Click(object sender, EventArgs e) { /*GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); * doc.DocumentName = "Preview Test"; * doc.DrawCellBox = true; * PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); * printPreviewDialog.ClientSize = new Size(600, 500); * printPreviewDialog.Location = new Point(29, 29); * printPreviewDialog.Name = "Print Preview Dialog"; * printPreviewDialog.UseAntiAlias = true; * printPreviewDialog.Document = doc; * printPreviewDialog.ShowDialog(); * doc.Dispose(); * doc = null;*/ GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); doc.DocumentName = "Preview Test"; doc.DrawCellBox = true; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
//used to display the print dialog private void buttonAdv4_Click(object sender, EventArgs e) { GridPrintDocument pd = new GridPrintDocument(this.gridGroupingControl1.TableControl); PrintDialog printDialog = new PrintDialog(); printDialog.Document = pd; pd.DefaultPageSettings.Landscape = true; if (printDialog.ShowDialog() == DialogResult.OK) { pd.Print(); } }
/// <summary> /// PrintPageLayout sample Customizations /// </summary> private void SampleCustomization() { pd = new GridPrintDocument(gridControl1); if (pd.PrinterSettings.IsValid) { layoutHelper = new LayoutSupportHelper(gridControl1); } gridControl1.HorizontalThumbTrack = true; gridControl1.VerticalThumbTrack = true; colorPickerButton1.ColorSelected += new EventHandler(colorPickerButton1_ColorSelected); colorPickerButton2.ColorSelected += new EventHandler(colorPickerButton2_ColorSelected); }
private void button2_Click(object sender, EventArgs e) { GridSelectedArea selArea = new GridSelectedArea(1, 2, 10, dataGridView1.RowCount - 3); GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); doc.SelectedArea = selArea; doc.DocumentName = "Preview Test"; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
/// <summary>Handles the Click event of the btnPrint control.</summary> private void btnPrint_Click(object sender, EventArgs e) { var doc = new GridPrintDocument(grdBilling, grdBilling.Font, true); doc.DocumentName = "Billing Report"; var printPreviewDialog = new PrintPreviewDialog { ClientSize = new Size(400, 300), Location = new Point(29, 29), Name = "Print Preview Dialog", UseAntiAlias = true, Document = doc }; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
private void button5_Click(object sender, EventArgs e) { GridPrintDocument doc = new GridPrintDocument(this.dataGridView1, this.dataGridView1.Font, true); doc.DocumentName = "Preview Test"; doc.DefaultPageSettings.Landscape = true; doc.DefaultPageSettings.PrinterSettings.FromPage = 1; doc.DefaultPageSettings.PrinterSettings.ToPage = 3; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
private void button1_Click(object sender, EventArgs e) { BindGrid(); GridPrintDocument doc = new GridPrintDocument(this.gvLog, this.gvLog.Font, true); doc.DocumentName = "Preview Test"; doc.DrawCellBox = true; doc.DefaultPageSettings.Landscape = true; PrintPreviewDialog printPreviewDialog = new PrintPreviewDialog(); printPreviewDialog.ClientSize = new Size(400, 300); printPreviewDialog.Location = new Point(29, 29); printPreviewDialog.Name = "Print Preview Dialog"; printPreviewDialog.UseAntiAlias = true; printPreviewDialog.Document = doc; printPreviewDialog.ShowDialog(); doc.Dispose(); doc = null; }
//used to display the printpreview dialog private void buttonAdv3_Click(object sender, EventArgs e) { // Print the contents of the grouping grid. GridPrintDocument pd = new GridPrintDocument(this.gridGroupingControl1.TableControl, true); PrintPreviewDialog ppv = new PrintPreviewDialog(); ppv.MouseWheel += ppv_MouseWheel; ppv.Document = pd; pd.DefaultPageSettings.Landscape = true; try { Icon ico = new Icon(Syncfusion.Windows.Forms.WinFormsUtils.FindFile("Icon", "sfgrid.ico")); ppv.FindForm().Icon = ico; } catch { } ppv.ShowDialog(); // NOTE: There is a known problem when the width of the nested table is larger // than the width of the parent table. Some columns that do not fit on the same // page as the last column of the parent table will be omitted. We are working // on a solution for this. }
private void printPreviewButton_Click(object sender, System.EventArgs e) { if (gridControl1 != null) { try { GridControl grid = this.splitterControl1.ActivePane as GridControl; if (grid != null) { GridPrintDocument pd = new GridPrintDocument(gridControl1, true); //Assumes the default printer PrintPreviewDialog dlg = new PrintPreviewDialog(); dlg.Document = pd; dlg.ShowDialog(); } } catch (Exception ex) { MessageBox.Show("An error occurred attempting to preview the file to print - " + ex.Message); } } }
private void createNewDocumentWith(DataGridView grid, bool landscape) { docToPrint = new GridPrintDocument(grid, grid.Font, true); if (grid.SelectedCells.Count > 1) { int minc, minr, maxc, maxr; minc = minr = int.MaxValue; maxc = maxr = 0; foreach (DataGridViewCell cell in grid.SelectedCells) { if (cell.ColumnIndex < minc) { minc = cell.ColumnIndex; } if (cell.ColumnIndex > maxc) { maxc = cell.ColumnIndex; } if (cell.RowIndex < minr) { minr = cell.RowIndex; } if (cell.RowIndex > maxr) { maxr = cell.RowIndex; } } var area = new GridSelectedArea(minc, minr, maxc, maxr); docToPrint.SelectedArea = area; } docToPrint.DocumentName = this.Text; docToPrint.DefaultPageSettings.Landscape = landscape; docToPrint.ShowMargin = true; docToPrint.DrawCellBox = true; }
private void printButton_Click(object sender, EventArgs e) { try { streamToPrint = new StreamReader("C:\\MyFile.txt"); try { //var pd = new PrintDocument(); //pd.PrintPage += PdPrintPage; //pd.Print(); var gridControlBase = new GridControlBase(); var gpd = new GridPrintDocument(gridControlBase); gpd.PrintPage += PdPrintPage; gpd.Print(); } finally { streamToPrint.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }