Hi,
I need to create a User Setting at run time. This setting will have multiple values (in other words, it will be of a Struct (with 2 variables in it)). I used below code. This code adds the new setting. but i am not able to assign the values to the setting.
public struct v_strct
{
public int v_int;
public int v_scr;
}
Code to add the multivalued setting:
v_strct v_tst = new v_strct();
System.Configuration.SettingsProperty pp = new System.Configuration.SettingsProperty("settingName");
pp.PropertyType = typeof(v_strct);
pp.Name = "settingname";
pp.IsReadOnly = false;
pp.Provider = Properties.Settings.Default.Providers["LocalFileSettingsProvider"];
pp.Attributes.Add(typeof(v_strct), new v_strct());
Properties.Settings.Default.Properties.Add(pp);
// Load settings now.
Properties.Settings.Default.Save();
//Properties.Settings.Default.
Properties.Settings.Default.Reload();
I am able to see the added setting using this code:
foreach (SettingsProperty sp in spc)
{
sp.Attributes.Add(v_tst, v_tst);
MessageBox.Show(sp.Name + Environment.NewLine + sp.Provider + Environment.NewLine
+ sp.PropertyType
+ Environment.NewLine + sp.Attributes.Keys
+ Environment.NewLine + sp.IsReadOnly
+ Environment.NewLine + sp.DefaultValue);
}
How do i assign values to it ?
Please feel free to correct the code as needed.
Thanks in advance.
-Giri.