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

User Control saving properties

P: n/a
Hello.
Can anyone tell me the proper way to save the properties of a user control
between design time and run time?

So, I've got this user control with the following properties:
BarColor1
BarColor2

I can access these properties in the property browser and change the colors.
But how to I have those changes persist between design time and run time for
the user control?
If the user of the control changes BarColor1 at design time, I want that to
persist to run time. And, if the user changes the color at run time, I want
that color to persist to the next instance of run time?
I'm using VS 2003.

Steve
Nov 17 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a

Save them to the <Settingsinformation for the project.

You can add them by double-clicking on "my project" in the
solution explorer. This brings up the project properties.
Click on the <Settingstab.

Add settings here. Each setting must have a
unique name, such as BarColor1, BarColor2, etc.

For Type, pick the type of value that it is; this
prevents you from having to convert it. There's
probably something like System.Color, or System.Drawing.Color.

Set the scope to User.

Then in your code, when the user changes it, save it to
the settings:

My.Settings.BarColor1 = whatever (must be same type)
Then when you want to use it, use My.Settings.BarColor1
instead of a color. It will retrieve the value from the Settings
and use it.

The .Net runtime saves the settings when the application is
closed, and reads them when it is opened.

Robin S.
-------------------------------------

"Steve Long" <St**********@NoSpam.comwrote in message
news:uu**************@TK2MSFTNGP06.phx.gbl...
Hello.
Can anyone tell me the proper way to save the properties of a user control
between design time and run time?

So, I've got this user control with the following properties:
BarColor1
BarColor2

I can access these properties in the property browser and change the
colors. But how to I have those changes persist between design time and
run time for the user control?
If the user of the control changes BarColor1 at design time, I want that
to persist to run time. And, if the user changes the color at run time, I
want that color to persist to the next instance of run time?
I'm using VS 2003.

Steve

Nov 18 '06 #2

P: n/a
Robin, there is no Settings tab in VS 2003 that I can see. Do you have one
in VS 2003?

Steve

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Qr******************************@comcast.com. ..
>
Save them to the <Settingsinformation for the project.

You can add them by double-clicking on "my project" in the
solution explorer. This brings up the project properties.
Click on the <Settingstab.

Add settings here. Each setting must have a
unique name, such as BarColor1, BarColor2, etc.

For Type, pick the type of value that it is; this
prevents you from having to convert it. There's
probably something like System.Color, or System.Drawing.Color.

Set the scope to User.

Then in your code, when the user changes it, save it to
the settings:

My.Settings.BarColor1 = whatever (must be same type)
Then when you want to use it, use My.Settings.BarColor1
instead of a color. It will retrieve the value from the Settings
and use it.

The .Net runtime saves the settings when the application is
closed, and reads them when it is opened.

Robin S.
-------------------------------------

"Steve Long" <St**********@NoSpam.comwrote in message
news:uu**************@TK2MSFTNGP06.phx.gbl...
>Hello.
Can anyone tell me the proper way to save the properties of a user
control between design time and run time?

So, I've got this user control with the following properties:
BarColor1
BarColor2

I can access these properties in the property browser and change the
colors. But how to I have those changes persist between design time and
run time for the user control?
If the user of the control changes BarColor1 at design time, I want that
to persist to run time. And, if the user changes the color at run time, I
want that color to persist to the next instance of run time?
I'm using VS 2003.

Steve


Nov 20 '06 #3

P: n/a
Oh dear, I have VS2005. In that case, I'm sorry, but
I don't know what the solution is. Anyone else?

Robin S.
----------------------------------

"Steve Long" <St**********@NoSpam.comwrote in message
news:uT**************@TK2MSFTNGP02.phx.gbl...
Robin, there is no Settings tab in VS 2003 that I can see. Do you have one
in VS 2003?

Steve

"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:Qr******************************@comcast.com. ..
>>
Save them to the <Settingsinformation for the project.

You can add them by double-clicking on "my project" in the
solution explorer. This brings up the project properties.
Click on the <Settingstab.

Add settings here. Each setting must have a
unique name, such as BarColor1, BarColor2, etc.

For Type, pick the type of value that it is; this
prevents you from having to convert it. There's
probably something like System.Color, or System.Drawing.Color.

Set the scope to User.

Then in your code, when the user changes it, save it to
the settings:

My.Settings.BarColor1 = whatever (must be same type)
Then when you want to use it, use My.Settings.BarColor1
instead of a color. It will retrieve the value from the Settings
and use it.

The .Net runtime saves the settings when the application is
closed, and reads them when it is opened.

Robin S.
-------------------------------------

"Steve Long" <St**********@NoSpam.comwrote in message
news:uu**************@TK2MSFTNGP06.phx.gbl...
>>Hello.
Can anyone tell me the proper way to save the properties of a user
control between design time and run time?

So, I've got this user control with the following properties:
BarColor1
BarColor2

I can access these properties in the property browser and change the
colors. But how to I have those changes persist between design time and
run time for the user control?
If the user of the control changes BarColor1 at design time, I want that
to persist to run time. And, if the user changes the color at run time,
I want that color to persist to the next instance of run time?
I'm using VS 2003.

Steve



Nov 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.