473,396 Members | 2,147 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Should Hashtables save in ApplicationSettings files?

I've been trying to save a hashtable in an Application Settings file.
I need to save settings for each tabPage on a form. Trouble is, the
number of tabPages is determined at runtime, so I can't have individual
settings for each page. I decided to hold them in a collection.

I started out with a generic Dictionary but that didn't work. So, I
created a new Forms app to test it out and created a Settings file. It
didn't offer me the generic Dictionary but did off the old Hashtable so
I tried that. It doesn't seem to save any values for the Hashtable:
Chair saves but table doesn't. This is my code: (the user.config that
results is at the end)
Any idea why Hashtable doesn't save anything. Any idea of a way round
this?

In form1's constructor (after InitializeComponent();):
Settings _settings = new Settings();
_settings.Chair = "Four-legged";
_settings.Table = new System.Collections.Hashtable();
_settings.Table.Add("First",
new TreeViewListViewSettings(View.Details));
_settings.Save();

Add a new object of type settings called Settings and use the Designer
to add these two items:
Name Type Scope Value
Table System.Collections.Hashtable User
Chair string User

A class to hold the values (I've only put one it is for clarity):
==========================
[Serializable()]
public class TreeViewListViewSettings
{
public TreeViewListViewSettings()
{
}
public TreeViewListViewSettings(View startingView)
{
_startingView = startingView;
}
public View StartingView
{
get { return _startingView; }
set { _startingView = value; }
}
private View _startingView;
}

user.config
===========
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ApplicationSettings.Settings"
type="System.Configuration.ClientSettingsSection, System,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ApplicationSettings.Settings>
<setting name="Chair" serializeAs="String">
<value>Four-legged</value>
</setting>
<setting name="Table" serializeAs="Xml">
<value />
</setting>
</ApplicationSettings.Settings>
</userSettings>
</configuration>

Apr 7 '06 #1
0 3569

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Anders Borum | last post by:
Hello! Now that generics are introduces with the next version of C#, I was wondering what kind of performance gains we're going to see, when switching from e.g. the general hashtable to a...
4
by: Anders Borum | last post by:
Hello! I have a list of singleton classes (model managers) that store objects internally using hashtables. Each of these classes use a single hashtable to store e.g. users, pages, elements and...
1
by: Curtis | last post by:
Does anyone know the proper method to save information to embedded hashtables. I am trying to save parent/child information to hashtables but I am not getting the correct results I have made a...
0
by: lawrence.farrell | last post by:
I have been developing a class library using Visual Studio 2005 in VB. I included an Application level setting in the project settings tab in the designer. I can access this setting using the...
0
by: Paul | last post by:
I have a windows form with ApplicationSettings bound to the location, clientsize, and windowstate. Theses settings were created and stored using the settings designer. The location, for instance,...
2
by: John | last post by:
I have a Win app in C#. I want to save the data the user enterere into textboxes and the selections the user made to comboboxes when the user close the app. So next time when the user launches the...
2
by: PAzevedo | last post by:
I have this Hashtable of Hashtables, and I'm accessing this object from multiple threads, now the Hashtable object is thread safe for reading, but not for writing, so I lock the object every time I...
7
by: Kamran Shafi | last post by:
Hi, I am creating an arraylist (say masterArrayList) of hashtables, where each hashtable (say table) is of the format key=string, value = arraylist of strings (say existing_strings). In a...
2
by: =?Utf-8?B?bXVzY2xla2luZw==?= | last post by:
say i have a form with many input text boxes, what is the proper way to store these values so when the next time the user opens the form, all the input from last session remains in the form? people...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.