Spread Disposal

Posted by: robinspicer on 8 September 2017, 12:48 pm EST

  • Posted 8 September 2017, 12:48 pm EST

    I am having a problem getting the spreadviews to dispose.  Once the spread object has been disposed, I have gone through the remaining spreadviews disposing each of them, but they still seem to be hanging around.  I'm using version 2.5.2011.2005 of FarPoint Spread for Windows Forms.
  • Replied 8 September 2017, 12:48 pm EST

    Hello,


    Are you talking about SpreadView or SheetView objects? By default the SpreadView objects should be disposed automatically when disposing the Spread. However, since SheetView objects can be shared in many Spread objects, they are not automatically disposed.


    There was a bug that should be fixed when we have the next maintenance release where children SpreadView objects are not being disposed of correctly when using the Spread control in a hierarchial mode.

  • Replied 8 September 2017, 12:48 pm EST

    I am talking about the sheetviews.  I realize that the sheetviews are not automatically being disposed, but I have code in the disposed method to loop through the sheetivews in the spread.sheets.  It is doing a .Dispose for each sheetview in the spread.sheets collection.  I have a generic spread that we have created that inherits from the Farpoint spread.  All of our controls that contain spreads use our genric spread.  I have added a PropertyError method that happens everytime a bound cell gets an error. Each control that has a spread on it also has a handler to the Property Error method inside our generic spread.   In this method it is checking that I am the spread that contains the focus since it is possible to have more than one spread up at a time.  If I am the spread that has focus and I recieved an error then the following code will occur.  The way out project is setup is that a user can open a form that is like a wizard that contains many spreads and you can open multiple wizrds at a time.  If I have opened up one wizard and I have moved to a screen that has a spread on it with 14 rows and I exit out of the wizard, then the disposed method for the spread that I was on occurs.  Then I go to my other opened wizard and move to a screen that has a spread on it and I cause and error to occur then the following method below gets called.   If I break on the first line of this method to see what Me it is referring to, the first time I break, the Me(spread) is the current spread that I am on, it has a Me.Parent that is the control that the spread is on,  then when it breaks again, the Me(spread) does not have a parent but the me.sheets(0).rowcount is 14 which leads me to believe it is still refering to the sheetview from the previous spread that we closed and the dispose method occured that got rid of the sheetviews and the spread.


    Private Sub PropertyError(ByVal sender As Object, ByVal e As xxx.Common.Classes.EntityValidationErrorArgs)


    If Me.ContainsFocus Then


    Dim sv As FarPoint.Win.Spread.SheetView = Me.GetRootWorkbook.GetActiveWorkbook.Sheets(0)


    RaiseEvent ErrorInSpread(Me, New ErrorInSpreadEventArgs(False))


    SpreadError = True


    sv.RowHeader.Rows(sv.ActiveRow.Index).BackColor = Color.Salmon


    sv.ActiveCell.BackColor = Color.Salmon


    sv.ActiveCell.Note = e.ErrorMessage


    sv.ActiveCell.NoteStyle = FarPoint.Win.Spread.NoteStyle.PopupNote


    sv.SetActiveCell(currentRow, currentColumn)


    End If


    End Sub


     

  • Replied 8 September 2017, 12:48 pm EST

    An instance of a disposed object will remain in memory if there are still references to it somewhere.  Are you detaching the event handler when the Spread and sheet are disposed?  The delegate will still be holding a reference if you are not.

    It is not clear how your event is getting wired up, so I cannot tell if that is what is happening, but that is what it sounds like.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels