templates

Posted by: kpk on 8 September 2017, 1:56 pm EST

  • Posted 8 September 2017, 1:56 pm EST

    I have a grid that is bound to a datatable.  Users are allowed to move columns and I would like to persist where columns have moved to from session to session.  is there a way I can serialize the layout but still maintain the binding?
  • Replied 8 September 2017, 1:56 pm EST

    Hello,


    You should be able to Serialize and Deserialize the layout using a Binary Serialization.Here is the code that Serialize the layout on ColumnMove and Deserialize the layout on a Button click event adding a new sheet to Spread.I hope it will help you.


    Private Sub FpSpread1_ColumnDragMoveCompleted(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.DragMoveCompletedEventArgs) Handles FpSpread1.ColumnDragMoveCompleted


    Dim stream As System.IO.Stream = System.IO.File.Open("save.bin", System.IO.FileMode.CreateNew)


    Dim binf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()


    binf.Serialize(stream, FpSpread1.Sheets(0))


    stream.Close()


    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click


    Dim binf As New System.Runtime.Serialization.Formatters.Binary.BinaryFormatter()


    Dim stream As System.IO.Stream = System.IO.File.Open("save.bin", System.IO.FileMode.Open)


    FpSpread1.Sheets.Add(binf.Deserialize(stream))


    End Sub


     


    Regards,

Need extra support?

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

Learn More

Forum Channels