windows forms version of IsPostback

fguihen

Junior Contributor
Joined
Nov 10, 2003
Messages
248
Location
Eire
is there anyway for a windows form to know if it has already been visited, or is being viewed for the first time? you see, i have a form, on which i have a tab control. in the first tab i create a dataRow which takes data from the form and creates a customer. the user continues through various tabs until they enter all required data and save the record. however if the first tab is visited again for whatever reason, another row with the details is generated, and this causes an error as you cant have two identical users. any ideas around this?
 
Automatically, I don't think so.

You could serialize (write it to a hard drive) and clear it when the application closes down or keep it if you like.

If you're going to keep track of more than one thing, like user and possibly statistics and other tidbits ("last used on...", "User name", etc) you might do well to design a datatable. If you're using 2005, it has an option to save to XML.

Really it takes like a minute or two to create the datatable as a schema and saving/loading it are only a single method call requiring the path.

If you only want to save if they've been there before for the "session" (this time the application was run) you can delete the xml file on closing the application.

On loading the form you're talking about, you can load the XML into a datatable and check to see if they're on the list.
 
Back
Top