Lets users select a printer and choose which sections of the document to print from a Windows Forms application.
Click here to download interface
using System;
using
System.Collections.Generic;
using
System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using
System.Windows.Forms;
using System.IO;
using System.Drawing;
namespace printDialog
{
public partial
class Form1
: Form
{
public Form1()
{
InitializeComponent();
}
private void
printDocument1_PrintPage(object sender,
System.Drawing.Printing.PrintPageEventArgs
e)
{
printPreviewControl1.InvalidatePreview();
SolidBrush
brsh = new SolidBrush(textBox1.ForeColor);
e.Graphics.DrawString(textBox1.Text, textBox1.Font, brsh, 10, 10);
}
private void
button1_Click(object sender, EventArgs e)
{
printPreviewDialog1.ShowDialog();
}
private void
button2_Click(object sender, EventArgs e)
{
if
(printDialog1.ShowDialog() == DialogResult.OK)
printDocument1.Print();
}
private void
button3_Click(object sender, EventArgs e)
{
pageSetupDialog1.ShowDialog();
}
}
}
click to download
No comments:
Post a Comment