From: John H. on
I am creating a large complex C# WinForm app under VS2008. I have
several custom controls where I need to save the history of user
entries. For example a search text entry box where I save the last 20
entries on a per user basis.

I had originally, thought that creating a .settings file for this
purpose would be the way to go. But, lists are difficult to work with
programmatically as Property settings.
What I have done is saved the history into a
System.Collections.Specialized.StringCollection object and then write
or read them to a disk folder with a BinaryFormatter.Serialize()
or .Deserialize object. I name the individual files in a way that
identifies the App, Form, Control, and user.

This works well, but it seems to me there may be a more straight
forward way to accomplish this. Is there a better way to track user
control history from session to session? Is there a mechanism built
into the .Net framework to handle this that I am not understanding?

Thanks,
John
From: Peter Duniho on
John H. wrote:
> I am creating a large complex C# WinForm app under VS2008. I have
> several custom controls where I need to save the history of user
> entries. For example a search text entry box where I save the last 20
> entries on a per user basis.
>
> I had originally, thought that creating a .settings file for this
> purpose would be the way to go. But, lists are difficult to work with
> programmatically as Property settings. [...]

Perhaps you could be more specific. I know it's possible to store lists
of strings with the Designer-provided Settings class, because I've done
it before. At the very least, you can just store some kind of delimited
string that you can turn back into a list (e.g. using String.Split()),
and my recollection is that it actually supports collections directly.

What trouble did you have exactly trying to store your lists in the
Settings class?

> [...]
> This works well, but it seems to me there may be a more straight
> forward way to accomplish this. Is there a better way to track user
> control history from session to session? Is there a mechanism built
> into the .Net framework to handle this that I am not understanding?

I'm not sure what you mean here. You have to store the data somewhere.
You can definitely store it in the Settings class, but if not there,
it's not like there's any more convenient way to persist data between
session. The whole point of the Settings class is for it to be the
"convenient" way.

Pete