private void navPrintResults_Click( object sender, EventArgs e ) { PrintPreviewDialog curPreviewDialog = new PrintPreviewDialog(); PrintDialog curPrintDialog = new PrintDialog(); DataGridView[] myViewList = new DataGridView[1]; myViewList[0] = slalomRecapDataGridView; bool CenterOnPage = false; bool WithTitle = true; bool WithPaging = true; Font fontPrintTitle = new Font( "Arial Narrow", 14, FontStyle.Bold ); Font fontPrintFooter = new Font( "Times New Roman", 10 ); curPrintDialog.AllowCurrentPage = true; curPrintDialog.AllowPrintToFile = false; curPrintDialog.AllowSelection = true; curPrintDialog.AllowSomePages = true; curPrintDialog.PrintToFile = false; curPrintDialog.ShowHelp = false; curPrintDialog.ShowNetwork = false; curPrintDialog.UseEXDialog = true; curPrintDialog.PrinterSettings.DefaultPageSettings.Landscape = true; if ( curPrintDialog.ShowDialog() == DialogResult.OK ) { String printTitle = Properties.Settings.Default.Mdi_Title + " - " + this.Text; myPrintDoc = new PrintDocument(); String curDocName = ""; String curAgeGroup = (String)TourEventRegDataGridView.CurrentRow.Cells["AgeGroup"].Value; String curSkierName = (String)TourEventRegDataGridView.CurrentRow.Cells["SkierName"].Value; String[] curNameParts = curSkierName.Split( ',' ); if ( curNameParts.Length > 1 ) { curDocName = curNameParts[1].Trim() + curNameParts[0].Trim() + "_" + curAgeGroup; } else if ( curNameParts.Length == 1 ) { curDocName = curNameParts[1].Trim() + curNameParts[0].Trim() + "_" + curAgeGroup; } else { curDocName = "Unknown"; } curSkierName += " " + curAgeGroup; myPrintDoc.DocumentName = curDocName; myPrintDoc.DefaultPageSettings.Margins = new Margins( 125, 125, 25, 25 ); myPrintDoc.DefaultPageSettings.Landscape = true; myPrintDataGrid = new DataGridViewPrinter( myViewList, myPrintDoc, CenterOnPage, WithTitle, printTitle, fontPrintTitle, Color.DarkBlue, WithPaging ); //Build titles for each data grid view myPrintDataGrid.GridViewTitleList(); StringRowPrinter myGridTitle; StringFormat GridTitleStringFormat = new StringFormat(); GridTitleStringFormat.Trimming = StringTrimming.Word; GridTitleStringFormat.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; GridTitleStringFormat.Alignment = StringAlignment.Near; myGridTitle = new StringRowPrinter( "Slalom Pass Round " + roundSelect.RoundValue, 0, 20, 325, fontPrintTitle.Height, Color.DarkBlue, Color.White, fontPrintTitle, GridTitleStringFormat ); myPrintDataGrid.GridViewTitleRow = myGridTitle; //Build report page subtitles myPrintDataGrid.SubtitleList(); StringRowPrinter mySubtitle; StringFormat SubtitleStringFormatLeft = new StringFormat(); SubtitleStringFormatLeft.Trimming = StringTrimming.Word; SubtitleStringFormatLeft.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormatLeft.Alignment = StringAlignment.Near; StringFormat SubtitleStringFormatCenter = new StringFormat(); SubtitleStringFormatCenter.Trimming = StringTrimming.Word; SubtitleStringFormatCenter.FormatFlags = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit | StringFormatFlags.NoClip; SubtitleStringFormatCenter.Alignment = StringAlignment.Center; mySubtitle = new StringRowPrinter( curSkierName, 0, 0, 325, fontPrintTitle.Height, Color.DarkBlue, Color.White, fontPrintTitle, SubtitleStringFormatLeft ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( scoreLabel.Text, 0, 25, 50, scoreLabel.Size.Height, Color.Black, Color.White, scoreLabel.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( scoreTextBox.Text, 0, 40, 50, scoreTextBox.Size.Height, Color.Black, Color.White, scoreTextBox.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( nopsScoreLabel.Text, 170, 25, 50, nopsScoreLabel.Size.Height, Color.Black, Color.White, nopsScoreLabel.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; mySubtitle = new StringRowPrinter( nopsScoreTextBox.Text, 170, 40, 55, nopsScoreTextBox.Size.Height, Color.Black, Color.White, nopsScoreTextBox.Font, SubtitleStringFormatCenter ); myPrintDataGrid.SubtitleRow = mySubtitle; myPrintDoc.PrinterSettings = curPrintDialog.PrinterSettings; myPrintDoc.DefaultPageSettings = curPrintDialog.PrinterSettings.DefaultPageSettings; myPrintDoc.PrintPage += new PrintPageEventHandler( printDoc_PrintPage ); curPreviewDialog.Document = myPrintDoc; curPreviewDialog.ShowDialog(); } }