By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,359 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,359 IT Pros & Developers. It's quick & easy.

Dynamic Default Settings in My.Settings

P: n/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
Sep 3 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Sep 3, 7:26*am, "AGP" <sindizzy....@softhome.netwrote:
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/libr...13(VS.80).aspx

Hope this helps,

Onur Guzel
Sep 3 '08 #2

P: n/a
AGP

"kimiraikkonen" <ki*************@gmail.comwrote in message
news:0b**********************************@l42g2000 hsc.googlegroups.com...
On Sep 3, 7:26 am, "AGP" <sindizzy....@softhome.netwrote:
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/libr...13(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
Sep 4 '08 #3

P: n/a
AGP wrote:
>
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.
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.
Sep 4 '08 #4

P: n/a
AGP

"Steve Gerrard" <my********@comcast.netwrote in message
news:9p******************************@comcast.com. ..
AGP wrote:
>>
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.

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
Sep 4 '08 #5

P: n/a
AGP wrote:
>
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.
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.
Sep 4 '08 #6

P: n/a
AGP

"Steve Gerrard" <my********@comcast.netwrote in message
news:nf******************************@comcast.com. ..
AGP wrote:
>>
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.

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
Sep 5 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.