Created
September 27, 2015 10:47
-
-
Save redknitin/260665d93f73dd4fb52f to your computer and use it in GitHub Desktop.
Printing in .NET
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Text; | |
using System.Windows.Forms; | |
namespace TryPrint1 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
//pageSetupDialog1.PageSettings = printDocument1.DefaultPageSettings; | |
//pageSetupDialog1.ShowDialog(); | |
//printDocument1.DefaultPageSettings = pageSetupDialog1.PageSettings; | |
printPreviewDialog1.Document = printDocument1; | |
printPreviewDialog1.ShowDialog(); | |
//if (printPreviewDialog1.ShowDialog() != DialogResult.OK) return; | |
//if (printDialog1.ShowDialog() != DialogResult.OK) return; | |
//printDocument1.PrinterSettings = printDialog1.PrinterSettings; | |
//printDocument1.Print(); | |
} | |
private void printDocument1_PrintPage(object sender, System.Drawing.Printing.PrintPageEventArgs e) | |
{ | |
var g = e.Graphics; | |
g.DrawString("Try the thingie", new Font("Arial", 12.0f, FontStyle.Regular), Brushes.Black, 20f, 20f); | |
//g.DrawRectangle(Pens.Black, new Rectangle(19, 19, 75, 25)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment