Dynamic Default Settings in My.Settings

A

AGP

VB.NET 2005
I've been working extensively with saving and loading my settings via the
My.Settings class. its worked out great except that i cant figure out how to
set a default setting that is dynamic. That is to say, the default property
changes per user or per machine. As an example, and this is only an example,
the default setting for the center of the screen. In the IDE I can set the
parameter as

ScreenCenter | System.Drawing.Point | User | "0,0"

the default here being 0,0 as i cant make that value dyanmic in the IDE.
Once the user has used the program and then closed then the actual value
gets updated and the default is no longer used. Is there a way to override
the deafult value with a dynamic value that is determined on startup. I have
more settings like this that need a default value to be determined
dynamically. In VB6 I could call the INI API and give it a default value
that could be dynamically determined. i was hoping there was also a
mechanism like this in VB.NET.

tia

AGP
 
K

kimiraikkonen

VB.NET 2005
I've been working extensively with saving and loading my settings via the
My.Settings class. its worked out great except that i cant figure out howto
set a default setting that is dynamic. That is to say, the default property
changes per user or per machine. As an example, and this is only an example,
the default setting for the center of the screen. In the IDE I can set the
parameter as

ScreenCenter  |   System.Drawing.Point   |   User     |   "0,0"

the default here being 0,0 as i cant make that value dyanmic in the IDE.
Once the user has used the program and then closed then the actual value
gets updated and the default is no longer used. Is there a way to override
the deafult value with a dynamic value that is determined on startup. I have
more settings like this that need a default value to be determined
dynamically. In VB6 I could call the INI API and give it a default value
that could be dynamically determined. i was hoping there was also a
mechanism like this in VB.NET.

tia

AGP

Are you meaning resetting settings to initial version or reloading
settings to most recently saved version?

Here is a good insight from page 4 from article:
http://www.devcity.net/Articles/281/4/article.aspx

And My.Settings has "Reset" and "Reload" methods:
http://msdn.microsoft.com/en-us/library/saa62613(VS.80).aspx

Hope this helps,

Onur Guzel
 
A

AGP

VB.NET 2005
I've been working extensively with saving and loading my settings via the
My.Settings class. its worked out great except that i cant figure out how
to
set a default setting that is dynamic. That is to say, the default
property
changes per user or per machine. As an example, and this is only an
example,
the default setting for the center of the screen. In the IDE I can set the
parameter as

ScreenCenter | System.Drawing.Point | User | "0,0"

the default here being 0,0 as i cant make that value dyanmic in the IDE.
Once the user has used the program and then closed then the actual value
gets updated and the default is no longer used. Is there a way to override
the deafult value with a dynamic value that is determined on startup. I
have
more settings like this that need a default value to be determined
dynamically. In VB6 I could call the INI API and give it a default value
that could be dynamically determined. i was hoping there was also a
mechanism like this in VB.NET.

tia

AGP

Are you meaning resetting settings to initial version or reloading
settings to most recently saved version?

Here is a good insight from page 4 from article:
http://www.devcity.net/Articles/281/4/article.aspx

And My.Settings has "Reset" and "Reload" methods:
http://msdn.microsoft.com/en-us/library/saa62613(VS.80).aspx

Hope this helps,

Onur Guzel

no i dont mean that. I mean what i stated...the default value for a setting
could be dynamic depending on the user. i know how to setup the settings but
the first time the user uses the program the default setting is based on
their computer, their screen, their user name, their OS, etc. The default is
dynamic depending on the user.

AGP
 
A

AGP

Steve Gerrard said:
I would claim that is not really a default anymore. But that's just
semantics.

Make a setting called "Initialized" which has a default (a real default)
of False. Check for that first. If it is false, then calculate and set all
the other settings, effectively ignoring their dummy default values. Then
set Initialized to True, and carry on.

ok but how does one go about using the same My.Settings class to do that. My
whole idea is to present the user with default properties by using the
My.Settings class. The screen was one example but lets say i would like him
to enter his user name and the default is his logon name and he could change
that at app startup. This is only an example but if i want to continue using
the My.Settings class then how would i dynamically change the default. Again
the INI API has a default that you can dynamically change and all im looking
for is a similar mechanism.

AGP
 
A

AGP

Steve Gerrard said:
First code that runs goes

If Not My.Settings.Initialized Then
My.Settings.UserName = My.User.Name
' set any other "dynamic defaults" here...
My.Settings.Initialized = True
My.Settings.Save()
End If

After that one time, the settings will behave as usual.

ok i see what you are saying. ill give that a shot. im surprised that MS
didnt add that as a feature. the My.Settings class is very useful on its own
but it still needs some work IMO. Does VS2008 support dynamic defaults?

AGP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top