1.窗体添加一个button
2.代码如下:
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.Drawing.Printing;
using System.Diagnostics;
using System.IO;
namespace printForm
{
public partial class Form1 : Form
{
private string stringToPrint;
public Form1()
{
InitializeComponent();
this.printDocument1.PrintPage += new PrintPageEventHandler(this.myPrinter_PrintPage);
}
private void myPrinter_PrintPage(object sender, PrintPageEventArgs e)
{
int charactersOnPage = 0;
int linesPerPage = 0;
e.Graphics.MeasureString(stri