Form上に配置しないSPREAD(FpSpread)から印刷ダイアログを表示できない
対象製品
SPREAD for Windows Forms 8.0J
詳細
Form上に配置しないSPREAD(FpSpread)を生成して印刷ダイアログを表示しようとすると、エラーメッセージが表示され、印刷ダイアログを表示できません。
【手順】
1.新規フォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.Buttonをクリックします
--エラーメッセージが表示され、印刷ダイアログが表示されません
【サンプルコード】
Public temp As FarPoint.Win.Spread.FpSpread
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
temp = New FarPoint.Win.Spread.FpSpread
temp.Sheets.Add(New FarPoint.Win.Spread.SheetView())
' テストデータの設定
temp.Sheets(0).Cells(1, 1).Value = "test"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim pi As New FarPoint.Win.Spread.PrintInfo
pi.ShowPrintDialog = True
temp.Sheets(0).PrintInfo = pi
temp.PrintSheet(0)
End Sub
【手順】
1.新規フォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.Buttonをクリックします
--エラーメッセージが表示され、印刷ダイアログが表示されません
【サンプルコード】
Public temp As FarPoint.Win.Spread.FpSpread
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
temp = New FarPoint.Win.Spread.FpSpread
temp.Sheets.Add(New FarPoint.Win.Spread.SheetView())
' テストデータの設定
temp.Sheets(0).Cells(1, 1).Value = "test"
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim pi As New FarPoint.Win.Spread.PrintInfo
pi.ShowPrintDialog = True
temp.Sheets(0).PrintInfo = pi
temp.PrintSheet(0)
End Sub
回避方法
以下のサンプルコードのように、印刷ダイアログ表示前にコントロールのバインド先のウィンドウ ハンドルを取得します。
【サンプルコード】
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' 回避策
Dim test As IntPtr = temp.Handle
Dim pi As New FarPoint.Win.Spread.PrintInfo
pi.ShowPrintDialog = True
temp.Sheets(0).PrintInfo = pi
temp.PrintSheet(0)
End Sub
【サンプルコード】
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
' 回避策
Dim test As IntPtr = temp.Handle
Dim pi As New FarPoint.Win.Spread.PrintInfo
pi.ShowPrintDialog = True
temp.Sheets(0).PrintInfo = pi
temp.PrintSheet(0)
End Sub