Work with annotation - How to save user annotation is SQL Server DB and restore it later?

Posted by: damianrm-fp on 8 September 2017, 2:24 pm EST

  • Posted 8 September 2017, 2:24 pm EST

    Dear FarPoint Team


    I review you example application for make annotation and I think that may be I can use it in my application. I have 2 questions:

     1. After user create his annotation, I should save it in database (SQL Server) and later when load grid to be able to restore it. Which command I need to use ? I hope you to have special commands for this which save all object at once, (may be in binary format?) other way it will be VERY hard work from me …

     2. What options I have user to be able insert short text messages, except his onw drawing ?


    I try to find answer of this in HELP, but it is not very good. Product (grid) is best, but seems to me that help is done only from automated software, which ONLY describe method and pramameters.

  • Replied 8 September 2017, 2:24 pm EST


    In order to save changes in the database at one go you need to call EndEdit method on each DataRow object in the DataSet/DataTable that corresponds with the row you made the change in using buttonClickEvent once you make all the changes in Spread:-


    foreach (DataRow row in (fpSpread1_Sheet1.DataSource as DataTable).Rows)


    However, I am unable to understand your second question as in are you talking about inserting new row of data in the Spread and then saving it in datatbase as well? Could you please reframe the question for us?


  • Replied 8 September 2017, 2:24 pm EST

    <SPAN style="FONT-FAMILY:'Arial','sans-serif';FONT-SIZE:10pt;mso-ansi-language:EN-US;">For question 1 –I guest that this commands will work, but not im my case because <SPAN style="mso-spacerun:yes;"> </SPAN>I do not use direct band/connect to DataSource, I write/read in FPSpread via reader/command object of ADO.NET and put values manual with grd.Sheet[0].SetValue </SPAN>

    <SPAN style="FONT-FAMILY:'Arial','sans-serif';FONT-SIZE:10pt;mso-ansi-language:EN-US;">So I need to get this annotation in a variable which value to save in SQL Server and later to be able to restore it. I guest that this variable will be binary stream?<o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:'Arial','sans-serif';FONT-SIZE:10pt;mso-ansi-language:EN-US;"> <o:p></o:p></SPAN>

    <SPAN style="FONT-FAMILY:'Arial','sans-serif';FONT-SIZE:10pt;mso-ansi-language:EN-US;">For second question I mean - I want to add annotation like this - I want to make 1 arrow and in the end of this arrow to write some text. This text should be in annotation, it can not be in rows of grid because in this rows of the grid has other info. I hope to become clearer now.<o:p></o:p></SPAN>

    <SPAN style="mso-ansi-language:EN-US;"><o:p><FONT size=3 face=Calibri> </FONT></o:p></SPAN>

  • Replied 8 September 2017, 2:24 pm EST

    Hello DamianRM,

    If i am able to comprehend your issue correctly then your issue is that you need to save the annotations (i.e. Cellnotes) in your Database and then retrieve it later on.

    If it is the case then you need two tables for it, Table1 will save the Spread cell's data and Table2 will save the cell notes if it exists along with the Row and Column index of the cell having Notes and these two table will be linked using foreign key. However, in order to save the cell notes we need to check each Spread cell note against the Empty String and then save it in Table2.

    In order to retrieve the cell notes we then have to use the Table2 and SetNote property of the DefaultSheetDataModel to set the cell notes of the cells in Table1 after retrieving it in Spread using Table2.

    For the second question as per my knowledge this is directly not possible with Spread. However, you can try using the Cell notes for that with NoteStyle set to StickNote, which you can edit it later on as well along with setting the NoteIndicatorColor to differentiate between the notes. Here is the code for the same:-


                fpSpread1.Sheets[0].AllowNoteEdit = true;
                fpSpread1.Sheets[0].Cells[1, 1, 3, 3].Note = "Test Note";
                fpSpread1.Sheets[0].Cells[1, 1, 3, 3].NoteIndicatorColor = Color.Green;
                fpSpread1.Sheets[0].Cells[1, 1, 3, 3].NoteStyle = FarPoint.Win.Spread.NoteStyle.StickyNote;


    Hope this will help you. Thanks.

Need extra support?

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

Learn More

Forum Channels