Thanks for pointing me in the right direction. I think I'm almost there, but I can't figure out what "type" needs to go in the code highlighted in red below. I keep getting the error "Type 'frmPrint' is not defined." I guess I'll just wait for you to get a chance to update the following code if its not an easy solution. I've attached the VB project as a zip file.
Copyright 2010 ESRI
'
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
'
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
'
' See the use restrictions at <your ArcGIS Explorer install location>/DeveloperKit/userestrictions.txt.
'
Imports Microsoft.VisualBasic
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Imports RustemSoft.DataGridViewColumns
Imports System.Drawing.Printing
Partial Public Class QueryResultsForm
Inherits Form
Public Sub New(ByVal data As ESRI.ArcGISExplorer.Data.TableBindingAdapter)
InitializeComponent()
' bind the data grid view to the table binding adapter
dataGridView1.DataSource = data
End Sub
Private PrintGrid As DataGridViewPrint
Private Sub buttonPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonPrint.Click
Dim fpr As New frmPrint()
With fpr
.ShowDialog()
If .Result > 0 Then
PrintGrid = New DataGridViewPrint(PrintDocument1, dataGridView1, .bBlackWhite)
PrintGrid.PrintTitle = .bTitle
PrintGrid.Title = .Title
Select Case .Result
Case 1 ' Print
' The Print method prints the DataGridView without using a print dialog.
' Use a PrintDialog when you want to offer the user the ability to choose print settings.
If PrintDialog1.ShowDialog() = DialogResult.OK Then PrintDocument1.Print()
Case 2 ' Page Setup
PageSetupDialog1.ShowDialog()
Case 3 ' Preview
PrintPreviewDialog1.Icon = fpr.Icon
PrintPreviewDialog1.ShowDialog()
End Select
End If
End With
End Sub
' Specify the output to print by handling the PrintPage event
' and by using the Graphics included in the PrintPageEventArgs.
Private Sub printDocument1_PrintPage(ByVal sender As Object, ByVal e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
' Print method of DataGridViewPrint class starts the custom DataGridView's printing process.
e.HasMorePages = PrintGrid.Print(e.Graphics)
End Sub
End Class