public static void FHDataGrid_btn_打印(string strPrintTittle, DataPager dataPager, DataGrid dataGrid, List <FHFormLb> listFormResult) { try { //生成自定义打印控件 PrintDocument print = new PrintDocument(); //打印列表集合 List <PrintDataGrid> listDataGrids = new List <PrintDataGrid>(); //每张页面所能承载的数量 int intCount = 45; //获取打印的总页数 int intPage = (int)Math.Ceiling((double)dataPager.list.Count / intCount); int j = 0; //循环打印每一页 for (int i = 0; i < intPage; i++) { //创建打印列表 PrintDataGrid datagrid = new PrintDataGrid(); //生成标题 datagrid.TitleInit(dataGrid.Columns); //循环添加数据 for (; j < intCount * (i + 1); j++) { if (j < dataPager.list.Count) { //if (j == 0) continue; datagrid.ItemsAdd(listFormResult[j]); } else { break; } } listDataGrids.Add(datagrid); } //循环添加每一个打印页 foreach (var item in listDataGrids) { print.Items_Add(strPrintTittle + DateTime.Now.ToShortDateString(), item.datagrid); } //打印窗体显示 print.Show(); } catch (Exception ex) { MethodLb.CreateLog(typeof(CommonMethod).FullName, "FHDataGrid_btn_打印", ex.ToString(), strPrintTittle, dataPager, dataGrid, listFormResult); } }