question for newbie at winforms

J

Jimmy Jim

Hey everyone, I come from a c#.net, vb.net background exclusively
writing web applications and have begun the process at also creating
WinForms.

Need some help understanding how to store information such as user
settings, etc. In ASP.NET, you simply store in a DB. If I create a
WinForms app and have someone set there name, for instance, in a
settings area. Where and how would be the best way to store this in a
WinForms app? Obviously, I can't rely on a DB because most people won't
have one installed on there machine.

So I guess, my entry level question is, how do most people store these?
Text files?

Thanks for your help!
JJ
 
J

John M Deal

Depending on the type of settings you are looking to set there are quite
a few options.

First there is the app.config file for any "static after installation"
type settings. These would be settings that the user can only set during
your installation process.

There is also Isolated Storage. You can look this up in the VS.Net help
files or on MSDN.

Next is storage of a custom "home-rolled" configuration file that you
store in the users data directory. To get to this you'll want to create
a folder and file under one of the well known user data locations. To
find these look into the Environment.GetFolderPath method.

Finally you can download the Configuration Management Application Block
out on MSDN. It handles a ton of different scenarios and can be extended
to meet new needs. I'd give you a link but seeing as how there are a
few you'd be best to just google for it.

Hope something here helps you out.

Have A Better One!

John M Deal, MCP
Necessity Software
 
G

Guest

Hi Jimmy

You can use Application.UserAppDataPath to get a folder path to the
Documents And Settings area on a per user / per application basis. In there,
you could use .NET serialization, an XML representation of a dataset, or an
Access database to store settings. Similarly, there is
Application.UserAppDataRegistry which gives you a Registry key location if
you want to store some data in the registry. In addition, you have
Application.CommonAppDataPath, and Application.CommonAppDataRegistry for
settings that would be shared between all users of an application on a
particular machine.

HTH

Nigel
 
J

Jimmy Jim

Great stuff Nigel. That was exactly what I was looking for!!!!

One more quick question concerning my new-ness at WinForms, say I have
a form that posts, in the WinForms world, do you post to the same
"window". For example, I have a form that collects data, looks up the
resposes, then will spit it into a datagrid. Do I put the datagrid on
the same form, and only show it upon postback?

If I should post this elsewhere, I will. Just thought it was a simple
question that you would be able to answer quickly.

Thanks again Nigel!!
 
G

Guest

Jimmy

It's funny - normally I deal with developers going the other way from
Desktop to Web...there is no postback! The data you collect on an input form
say in a DataGrid can be bound to a DataSet, you can make multiple changes to
multiple rows of the grid, then flush all the changes from the bound DataSet
to the database with a single call to a DataAdapter. There's no need to deal
with the issues relating to state management over HTTP (until you come to
creating a distributed application).

HTH

Nigel Armstrong
 
J

Jimmy Jim

Awesome stuff!! Thanks for all the help, I am sure to be on here again
with more questions as I am really new at the WinForms stuff, but
loving it so far.

Take care,
JJ
 
M

Mark Broadbent

Its where I started too Jimmy -there's always something to learn and some
great people here.
Welcome to the community!

--
Best Regards,

Mark

Mark Broadbent

mcad,mcdba,mcse+i
emailto: newsgroupsATmettayyaDOTgotadslDOTcoDOTuk
remove AT with '@' and DOT with '.' -please do not send spam or address will
be changed!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top