Posted 11 July 2019, 6:08 am EST
We are upgrading our spread to the newest version. A problem we are experiencing is with Sheetview.Parent.RecalculateAll after editing a cell in the childview row. It is giving a System.Exception within the spread internal code.
System.Exception: Exception handled in FpSpread.WndProc —> System.NullReferenceException: Object reference not set to an instance of an object.
at FarPoint.Win.Spread.SpreadView.a(Control A_0)
at FarPoint.Win.Spread.SpreadView.dj()
at FarPoint.Win.Spread.SpreadView.ah(Boolean A_0)
at FarPoint.Win.Spread.SpreadView.o(Object A_0, EventArgs A_1)
at FarPoint.Win.Spread.CellType.BaseCellType.FireEditingStopped()
at FarPoint.Win.Spread.CellType.EditBaseCellType.StopEditing()
at FarPoint.Win.Spread.SpreadView.aj(Boolean A_0)
at FarPoint.Win.Spread.SpreadView.StopCellEditing()
Here is simple code to recreate…
Create a Form with FpSpread(12.45.20191.0), insert the following code, and run.
- Open a row to create a childview.
- Edit the Name cell.
Imports FarPoint.Win.Spread
Public Class Form1
Private WithEvents BindingSource As New BindingSource
Private Tests As New List(Of TestClass)
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
LoadForm()
End Sub
Private Sub LoadForm()
Tests.Add(New TestClass(1, New List(Of TestClass2)({New TestClass2("Name1")})))
Tests.Add(New TestClass(2, New List(Of TestClass2)({New TestClass2("Name2")})))
Tests.Add(New TestClass(3, New List(Of TestClass2)({New TestClass2("Name3")})))
BindingSource.DataSource = Tests
FpSpread1_Sheet1.ColumnCount = 2
FpSpread1_Sheet1.DataSource = BindingSource
FpSpread1_Sheet1.Columns(0).DataField = "Id"
FpSpread1_Sheet1.Columns(1).DataField = "Stuff"
FpSpread1_Sheet1.Columns(1).Visible = False
End Sub
Private Sub FpSpread1_ChildViewCreated(sender As Object, e As ChildViewCreatedEventArgs) Handles FpSpread1.ChildViewCreated
With e.SheetView
.ColumnCount = 1
.Columns(0).DataField = "Name"
.Columns(0).CellType = New FarPoint.Win.Spread.CellType.TextCellType
End With
End Sub
Private Sub FpSpread1_EditModeOff(sender As Object, e As EventArgs) Handles FpSpread1.EditModeOff
Dim sheetView As FarPoint.Win.Spread.SheetView = FpSpread1.GetRootWorkbook.GetActiveWorkbook.Sheets(0)
If sheetView IsNot Nothing _
AndAlso sheetView.Parent IsNot Nothing Then
sheetView.Parent.RecalculateAll()
End If
End Sub
Public Class TestClass
Public Property Id As String
Public Property Stuff As List(Of TestClass2)
Sub New(ByVal id As Integer, ByVal stuff As List(Of TestClass2))
Me.Id = id
Me.Stuff = stuff
End Sub
End Class
Public Class TestClass2
Public Property Name As String
Sub New(ByVal name As String)
Me.Name = name
End Sub
End Class
End Class