private void Doc_PrintPage(object sender, PrintPageEventArgs e) { float lineHeight = e.MarginBounds.Top; FilesDocument files = (FilesDocument)sender; files.PrintFilesPage(e); }
private void btnPrint_Click(object sender, EventArgs e) { printList = fileData.SelectAllFiles().ToList(); //Create the printdocument and attach an event handler PrintDocument doc = new FilesDocument(printList); doc.PrintPage += Doc_PrintPage; PrintDialog dlgSettings = new PrintDialog(); dlgSettings.Document = doc; if (dlgSettings.ShowDialog() == DialogResult.OK) { doc.Print(); Logger.WriteToFile(Logger.FullName, "printed a file"); } }