c# datagridview 打印只打一页,不能多页打印,请高手帮忙。
首先是一个类:
namespace schoolInformation
{
public class Printer
{
private DataGridView dataview;
private PrintDocument printDoc;
//打印有效区域的宽度
int width;
int height;
int columns;
double Rate;
bool hasMorePage = false;
int currRow = 0;
int rowHeight = 20;
//打印页数
int PageNumber;
//当前打印页的行数
int pageSize = 20;
//当前打印的页码
int PageIndex;
private int PageWidth; //打印纸的宽度
private int PageHeight; //打印纸的高度
private int LeftMargin; //有效打印区距离打印纸的左边大小
private int TopMargin;//有效打印区距离打印纸的上面大小
private int RightMargin;//有效打印区距离打印纸的右边大小
private int BottomMargin;//有效打印区距离打印纸的下边大小
int rows;
public Printer(DataGridView dataview, PrintDocument printDoc)
{
this.dataview = dataview;
this.printDoc = printDoc;
PageIndex = 0;
//获取打印数据的具体行数
this.rows = dataview.RowCount;
this.columns = dataview.ColumnCount;
//判断打印设置是否是横向打印
if (!printDoc.DefaultPageSettings.Landscape)
{
PageWidth = printDoc.DefaultPageSettings.PaperSize.Width;
PageHeight = printDoc.DefaultPageSettings.PaperSize.Height;