Reputation: 6731
I have an Excel 2010, VSTO application in C# that I'm working on. I have created a WinForm that uses a XSD data collection to take in user input on the form. How can I get the data within this XSD to persist from one use of the workbook to the other? Obviously, I'd need to come up with some sort of a "Save" routine when the data is entered and I'd also like to find a routine to populate the form on a subsequent use (with the previously saved data). I have been unable to find a reliable source for VSTO examples like this.
Upvotes: 0
Views: 621
Reputation: 3702
Take a look at this CodeProject page, Saving the state (serializing) a Windows Form. I've used it in Excel VSTO applications that incorporated WinForms and it works beautifully. It's also very easy to customize it to include any of your controls that are not already built into the class, as well as change the format of how the control data is saved, etc.
In short, you are able to do two calls in your code:
FormSerialisor.Serialise(this, myPath + @"\myFormName.xml");
and
FormSerialisor.Deserialise(this, myPath + @"\myFormName.xml");
Very simple and very fast. It's written in C#, but it can be used in VB.Net projects as well by compiling the class and then referencing the .dll
Upvotes: 1