Hi,
When creating a Property in a Settings file, it is possible to select the desired type for your property. I want to have a HashTable (or another key-value collection) in my settings file.
At first is it not possible to hava a default value for the HashTable. So, no problem, in my code I initialize the HashTable to new, I put my values in it and I save the properties file. So far, everything goes fine, no error. But when I want to read again my saved properties, I see that nothing has been saved!!!
Any suggestions? Below an example of what I'm trying to do...
private
void AbstractChildForm_Load(object sender, EventArgs e)
{
if (Properties.FormSettings.Default.FormLocations != null &&Properties.FormSettings.Default.FormLocations[Name] != null)
{
int[] values = Properties.FormSettings.Default.FormLocations[Name] as int[];
this.Location = new Point(values[0], values[1]);
this.Size = new Size(values[2], values[3]);
}
}
}
private void AbstractChildForm_FormClosing(object sender, FormClosingEventArgs e)
{
int[] values = new int[4];
values[0] =
this.Location.X;
values[1] =
this.Location.Y;
values[2] =
this.Size.Width;
values[3] =
this.Size.Height;
if (Properties.FormSettings.Default.FormLocations == null)
{
Properties.
FormSettings.Default.FormLocations = new System.Collections.Hashtable();
}
Properties.
FormSettings.Default.FormLocations[Name] = values;
Properties.
FormSettings.Default.Save();
}
Thanks
Regards Simon