作成日: 2014/09/26 最終更新日: 2017/09/22
文書種別
使用方法
詳細
C1PrintPreviewControlコントロールのツールバーの[印刷]ボタンをクリックすると印刷ダイアログが表示されますが、UserActionイベントハンドラで既定の処理をキャンセルしてから、印刷処理を実装することにより、印刷ダイアログで[OK]または[キャンセル]ボタンのどちらが選択されたのかを調べることができます。
◎サンプルコード(VB)
◎サンプルコード(C#)
◎サンプルコード(VB)
Private Sub C1PrintPreviewControl1_PreviewPane_UserAction(sender As Object, e As C1.Win.C1Preview.UserActionEventArgs) Handles C1PrintPreviewControl1.PreviewPane.UserAction
' アクションの種類を判定します。
If e.PreviewAction = C1.Win.C1Preview.C1PreviewActionEnum.Print Then
' 既定の印刷処理をキャンセルします。
e.Cancel = True
' 印刷を実行します。
If C1PrintPreviewControl1.PreviewPane.Print Then
MessageBox.Show("印刷を実行しました")
Else
MessageBox.Show("印刷をキャンセルしました")
End If
End If
End Sub
' アクションの種類を判定します。
If e.PreviewAction = C1.Win.C1Preview.C1PreviewActionEnum.Print Then
' 既定の印刷処理をキャンセルします。
e.Cancel = True
' 印刷を実行します。
If C1PrintPreviewControl1.PreviewPane.Print Then
MessageBox.Show("印刷を実行しました")
Else
MessageBox.Show("印刷をキャンセルしました")
End If
End If
End Sub
◎サンプルコード(C#)
private void c1PrintPreviewControl1_PreviewPane_UserAction(object sender, C1.Win.C1Preview.UserActionEventArgs e)
{
// アクションの種類を判定します。
if (e.PreviewAction == C1.Win.C1Preview.C1PreviewActionEnum.Print)
{
// 既定の印刷処理をキャンセルします。
e.Cancel = true;
// 印刷を実行します。
if (c1PrintPreviewControl1.PreviewPane.Print())
{
MessageBox.Show("印刷を実行しました");
}
else
{
MessageBox.Show("印刷をキャンセルしました");
}
}
}
{
// アクションの種類を判定します。
if (e.PreviewAction == C1.Win.C1Preview.C1PreviewActionEnum.Print)
{
// 既定の印刷処理をキャンセルします。
e.Cancel = true;
// 印刷を実行します。
if (c1PrintPreviewControl1.PreviewPane.Print())
{
MessageBox.Show("印刷を実行しました");
}
else
{
MessageBox.Show("印刷をキャンセルしました");
}
}
}
旧文書番号
69982