Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2007

Tip: Looking for answers? Try searching our database.

New setting at runtime

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
e-mre - 30 May 2007 14:05 GMT
Is it possible to add a new record to the settings file at run-time? Or is
the only possible time to add a new setting is design-time?

There are many many thing in my application that the user can customize for
him/her. I am thinking of stroring these in the settings file on the user PC
but I don't want to open a new record in the settings file for each
customizable setting.
If the setting is not in the settings file then use the default. If the user
changes from the default then add a new record to the settings file and save
the non-default value to the settings file.

e-mre
Peter Duniho - 30 May 2007 19:45 GMT
> Is it possible to add a new record to the settings file at run-time? Or  
> is the only possible time to add a new setting is design-time?

Depends on what you mean.  The settings you add in the designer are added  
as properties to the Settings class.  Obviously you can't do that at  
run-time.

> There are many many thing in my application that the user can customize  
> for him/her. I am thinking of stroring these in the settings file on the  
> user PC but I don't want to open a new record in the settings file for  
> each customizable setting.

IMHO, this is not a very useful feature.  Your settings file should not be  
very large, no matter how many settings you put into it.  Further, if it's  
a problem for the file to be large enough to contain all possible  
settings, then that's a problem for the user who does change all possible  
settings.  I doubt you're in that situation, but if you are, you need to  
reconsider your use of the settings storage.

And of course, if you're not, then it's not a good use of your time to try  
to figure out how to avoid writing out settings that are not changed from  
the default.

All that said, if you still decide you really want to do this, you should  
be able to use the built-in XML-writing support to essentially implement  
your own Settings class that does what you want.  I think you could  
probably override the Save() method in the Settings class (it's defined as  
"partial" so you could add new code in a different .cs file), enumerating  
the properties yourself and saving only those that differ from the  
default.  But since I haven't tried that, I don't really know how hard  
that would be and what sort of pitfalls await you.

Pete
Jeffrey Tan[MSFT] - 04 Jun 2007 04:02 GMT
Hi E-mre ,

Have you reviewed Peter's reply to you? Does it make sense to you? If you
still need any help or have any concern, please feel free to feedback,
thanks.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.