Home All Groups Group Topic Archive Search About

User Control saving properties

Author
17 Nov 2006 7:23 PM
Steve Long
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

Author
18 Nov 2006 7:17 PM
RobinS
Save them to the <Settings> information 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 <Settings> tab.

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.
-------------------------------------



Show quoteHide quote
"Steve Long" <Steve_Noneya@NoSpam.com> wrote in message
news:uux6Q3nCHHA.3916@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
>
Author
20 Nov 2006 3:54 PM
Steve Long
Robin, there is no Settings tab in VS 2003 that I can see. Do you have one
in VS 2003?

Steve

Show quoteHide quote
"RobinS" <RobinS@NoSpam.yah.none> wrote in message
news:Qr2dnS_VBMv5wcLYnZ2dnUVZ_t6dnZ2d@comcast.com...
>
> Save them to the <Settings> information 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 <Settings> tab.
>
> 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" <Steve_Noneya@NoSpam.com> wrote in message
> news:uux6Q3nCHHA.3916@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
>>
>
>
Author
20 Nov 2006 7:00 PM
RobinS
Oh dear, I have VS2005. In that case, I'm sorry, but
I don't know what the solution is. Anyone else?

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

Show quoteHide quote
"Steve Long" <Steve_Noneya@NoSpam.com> wrote in message
news:uTlqgwLDHHA.1196@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" <RobinS@NoSpam.yah.none> wrote in message
> news:Qr2dnS_VBMv5wcLYnZ2dnUVZ_t6dnZ2d@comcast.com...
>>
>> Save them to the <Settings> information 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 <Settings> tab.
>>
>> 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" <Steve_Noneya@NoSpam.com> wrote in message
>> news:uux6Q3nCHHA.3916@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
>>>
>>
>>
>
>