SuspendLayoutメソッド~ResumeLayoutメソッド呼び出しの間にShowActiveCellメソッドを実行すると例外が発生する場合がある
対象製品
SPREAD for Windows Forms 8.0J
状況
修正済み
詳細
アクティブセルが固定領域にある場合、SuspendLayoutメソッド~ResumeLayoutメソッド呼び出しの間にShowActiveCellメソッドを実行すると例外(System.IndexOutOfRangeException)が発生します。
【手順】
1.新規フォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.Buttonをクリックします
--例外(System.IndexOutOfRangeException)が発生します
【サンプルコード】
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With Me.FpSpread1
.ActiveSheet.FrozenColumnCount = .ActiveSheet.ColumnCount
.ActiveSheet.FrozenRowCount = .ActiveSheet.RowCount
.SuspendLayout()
Try
.ActiveSheet.SetActiveCell(0, 0)
.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Nearest)
Finally
.ResumeLayout(True)
End Try
End With
End Sub
【手順】
1.新規フォームにSPREADとButtonを配置します
2.下記サンプルコードをコピーし、アプリケーションを実行します
3.Buttonをクリックします
--例外(System.IndexOutOfRangeException)が発生します
【サンプルコード】
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
With Me.FpSpread1
.ActiveSheet.FrozenColumnCount = .ActiveSheet.ColumnCount
.ActiveSheet.FrozenRowCount = .ActiveSheet.RowCount
.SuspendLayout()
Try
.ActiveSheet.SetActiveCell(0, 0)
.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Nearest)
Finally
.ResumeLayout(True)
End Try
End With
End Sub
回避方法
Service Pack 2(v8.0.3503.2008)で修正済み。
Service Pack 2(v8.0.3503.2008)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
ShowActiveCellメソッドを実行する前に一時的にResumeLayoutメソッドを実行して描画行います。
【サンプルコード】
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
With Me.FpSpread1
.ActiveSheet.FrozenColumnCount = .ActiveSheet.ColumnCount
.ActiveSheet.FrozenRowCount = .ActiveSheet.RowCount
.SuspendLayout()
Try
.ActiveSheet.SetActiveCell(0, 0)
.ResumeLayout() ' 回避策[1/2]
.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Nearest)
.SuspendLayout() ' 回避策[2/2]
Finally
.ResumeLayout(True)
End Try
End With
End Sub
Service Pack 2(v8.0.3503.2008)より前のバージョンでは次の回避方法が有効です。
------------------------------------------
ShowActiveCellメソッドを実行する前に一時的にResumeLayoutメソッドを実行して描画行います。
【サンプルコード】
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
With Me.FpSpread1
.ActiveSheet.FrozenColumnCount = .ActiveSheet.ColumnCount
.ActiveSheet.FrozenRowCount = .ActiveSheet.RowCount
.SuspendLayout()
Try
.ActiveSheet.SetActiveCell(0, 0)
.ResumeLayout() ' 回避策[1/2]
.ShowActiveCell(FarPoint.Win.Spread.VerticalPosition.Nearest, FarPoint.Win.Spread.HorizontalPosition.Nearest)
.SuspendLayout() ' 回避策[2/2]
Finally
.ResumeLayout(True)
End Try
End With
End Sub