The trick is to catch the ApplicationExit event. This is done by writing an event handler that will be invoked when the form is closed. I personally use the application exit as my trigger. You could also use the FormClosing event. An example:
void Application_Exit ( object sender,
EventArgs e )
{
}
Then declare the event handler in your form constructor, like:
Application.ApplicationExit +=
new EventHandler (
Application_Exit );
Also in your form constructor include code to determine if there is any earlier saved data. The mere existence of a file should be sufficient. If so, retrieve it and populate your DataGrid.
Make sure that you save the user's data in a user-accessible user-unique file. I recommend against using cookies as they may be prohibited on the machine.
Hope that helps.