Solved

Save User Settings

Posted on 2004-09-11
4
193 Views
Last Modified: 2010-04-23
I still after reading several articles to save user prefernces am very lost.

These are the settings I need to save.

Image.Checkbox
Desc.Checkbox

Windows Program size

Heres the doozy:

I have a search form, as the user enter the field to search for.  If they choose to they can save that text to thier favorites.
Then I will have them click a favorite button(favbtn) that will display there saved strings.  When selected it will fill the txtbox for a search.

I just have a problem witht the saving of the favorites.  I would prefer and Ini file as it seems easier to use, or xml, but I would like to stay away from the registry.

Thanks for all the help, This site ROCKS.


MJ
0
Comment
Question by:malanois
  • 2
4 Comments
 
LVL 4

Expert Comment

by:Jigit
ID: 12037437
malanois, you are right  - XML seems to be reasonable solution. I would suggest the following schema:
<USERS>
  <USER username="john">
    <IMAGE></IMAGE>
    <DESCR></DESCR>
  </USER>
  <USER username="anny">
    <IMAGE></IMAGE>
    <DESCR></DESCR>
  </USER>
</USERS>

Samples for reading and writing XML:
http://samples.gotdotnet.com/quickstart/howto/doc/Xml/DOMInterfaceXmlDocument.aspx
http://www.devasp.com/search/display/category614.html

HTH,
Jigit
0
 

Author Comment

by:malanois
ID: 12038199
I have read thos before.

this is  a winforms program.

I still cannot get it to write or read

Thanks
MJ
0
 
LVL 4

Expert Comment

by:Jigit
ID: 12038497
It does not really matters whether it's WinForms or WebForms. Could you publish your source code here, I'll try to figure out what you did wrong.
0
 
LVL 2

Accepted Solution

by:
Mehrdad_Y earned 500 total points
ID: 12039110
I think
1- You have to add a Typed Dataset to your project. (From the solution explorer, Add a new item, DataSet)
2- Add a Table to it to define all the data you need to store. (Add an ELEMENT from the toolbox to your dataset, name it, then add your fields with data types)
3- Anytime you need to save some data, use the following code: (I assume, you name your dataset as DATASET1)
   Dim ds As New Dataset1
   Dim r As New Dataset1.Table1Row=ds.Table1.NewRow
   r.[Preference1]=[Value1]
   r.[Preference2]=[Value2]
   ...
   ds.Table1.Rows.Add(r)
   ds.WriteXML([FilePath])

4- Anytime you need to load the data, write the following code:
   Dim ds As New Dataset1
   ds.ReadXML([FilePath])
   [Value1]=ds.Table1.Rows([INDEX YOU NEED]).[Preference1]
   ....
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now