バージョン

PrintPreview() メソッド

グリッドデータのレポートがどのように印刷されるかを示すプレビューの作成を開始します。
シンタックス
'宣言
 
Public Overloads Sub PrintPreview() 
public void PrintPreview()
解説

PrintPreview メソッドは印刷プレビューを開始します。このメソッドをトリガーするとグリッドのデータに基づく印刷されたレポートを準備して印刷プレビューウィンドウに結果を表示するプロセスを開始します。このプロセスには複数のステップがあり、コントロール内で印刷プレビュー固有のオブジェクトとイベントの間のやりとりがあります。

印刷プレビューが開始すると、InitializePrintPreview イベントが発生します。このイベントは、プレビューされる印刷ジョブについての情報を含む PrintDocument オブジェクトを受け取ります。このオブジェクトのプロパティを検証および変更して、ユーザーへのフィードバックを提供し、印刷様式を制御します。

使用例
Imports Infragistics.Shared
Imports Infragistics.Win
Imports Infragistics.Win.UltraWinGrid
Imports System.Drawing.Printing

  Private Sub Button16_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button16.Click

      ' Following code shows a print preview dialog and then prints the UltraGrid.

      Try
          ' Optinally show the print preview dialog.
          Me.ultraGrid1.PrintPreview()

          ' Calling print causes the UltraGrid to send the print job to the printer.
          Me.ultraGrid1.Print()
      Catch exc As Exception
          ' Catch any exceptions that may get thrown and let the user know.
          MessageBox.Show("Error occured while printing." & vbCrLf & exc.Message, "Error printing", _
                                      MessageBoxButtons.OK, MessageBoxIcon.Error)
      End Try

  End Sub

  Private Sub UltraGrid1_BeforePrint(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs) Handles ultraGrid1.BeforePrint

      ' Following code shows a message box giving the user a last chance to cancel printing the 
      ' UltraGrid.
      Dim result As DialogResult = MessageBox.Show("Proceed with printing ?", "Confirm", MessageBoxButtons.OKCancel, MessageBoxIcon.Question)
      If DialogResult.Cancel = result Then e.Cancel = True

  End Sub
using Infragistics.Shared;
using Infragistics.Win;
using Infragistics.Win.UltraWinGrid;
using System.Diagnostics;
   using System.Drawing.Printing;

private void button16_Click(object sender, System.EventArgs e)
{	

	// Following code shows a print preview dialog and then prints the UltraGrid.

	try
	{
		// Optinally show the print preview dialog.
		this.ultraGrid1.PrintPreview( );

		// Calling print causes the UltraGrid to send the print job to the printer.
		this.ultraGrid1.Print( );			
	}
	catch ( Exception exc )
	{
		// Catch any exceptions that may get thrown and let the user know.
              
		MessageBox.Show( "Error occured while printing.\n" + exc.Message, "Error printing", 
			MessageBoxButtons.OK, MessageBoxIcon.Error );
	}

}
		
private void ultraGrid1_BeforePrint(object sender, Infragistics.Win.UltraWinGrid.CancelablePrintEventArgs e)
{

	// Following code shows a message box giving the user a last chance to cancel printing the 
	// UltraGrid.

	DialogResult result = MessageBox.Show( "Proceed with printing ?", "Confirm", 
		MessageBoxButtons.OKCancel, MessageBoxIcon.Question );
	
	if ( DialogResult.Cancel == result )
		e.Cancel = true;

}
参照