Cell Range Data Binding / Inserting new records?

Posted by: jose4spread on 8 September 2017, 1:32 pm EST

  • Posted 8 September 2017, 1:32 pm EST

    Hi,


    I am trying to use the Cell Range Data Binding to allow adding new records to a table (Windows Forms Spread 4.0). According to the help (below) it should be possible.


    The test that I am assemblying is not working, I cannot insert a row in the table using .AddRows or .AddUnboundRows, in both cases it fails with an exception (very general exception).


     Is there a sample to look at? any pointer is appreciatted.


     Thanks, José Araujo.


    Help: "The data source and the cell range in the Spread are controlled by the MapperInfo class. They synchronize with each other via row synchronization. If the user adds or removes any row in the cell range, it will affect the data source and vice versa. If the user adds a new row right below the existing bound cell range, the cell range will expand one row and make the MapperInfo class and data source expand and vice versa. If the new row is added outside of the bound area, then it is not added to the bound range."

  • Replied 8 September 2017, 1:32 pm EST

    Hello,


    You want to use the Add or AddRange methods on the Rows object. Using the sample I sent you before, you can use the following code to add a row to the Spread and the MapperInfo and bound DataSource will update to include the new Row. You need to make sure the DataColumn is not set to ReadOnly.


    FpSpread1.Sheets(0).Rows.Add(8, 1)

  • Replied 8 September 2017, 1:32 pm EST

    Hi,


     I will try that out, but what about if I want the user to change it? let's say the user copies the current data into Excel, makes some changes (including adding a new row), and paste that back to the spread control, will the new row be included in the underlying dataset automatically?


    Thanks for the info...  José.

  • Replied 8 September 2017, 1:32 pm EST

    Jose,


    It will not. You would need to programatically need to add a row(s) before the paste if you want to add the rows to the bound range.

  • Replied 8 September 2017, 1:32 pm EST

    Scott,


    Thanks. That's what I needed to know.


    I appreciate your support, it really gives value to the product. Good job.


    José.

Need extra support?

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

Learn More

Forum Channels