You can save this information to the <Settings>
information for the project.
You can add this info by double-clicking on "my project"
in the solution explorer. This brings up the project
properties. Click on the <Settingstab.
Add the settings here. Each setting must have a
unique name, such as ProductTextBoxColor,
CustomerTextBoxColor, etc.
For Type, set it to System.Drawing.Color.
Set the scope to User.
Then in your code, when the user changes it, save it to
the settings:
My.Settings.ProductTextBoxColor = Color.PaleVioletRed
Then when you want to use it, use My.Settings.ProductTextBoxColor
instead of a color. It will retrieve the value from the Settings
and use it.
ProductTextBox.BackColor = My.Settings.ProductTextBoxColor
The .Net runtime saves the settings when the application is
closed, and reads them when it is opened.
You can use the ColorDialog to allow the user to select
a color. I would save it to My.Settings at that point,
then turn around and assign it using My.Settings.ProductTextBoxColor;
this way you can ensure that it's working properly.
Robin S.
"Henry Jones" <he***@yada.comwrote in message
news:eM**************@TK2MSFTNGP06.phx.gbl...
>I wanted to convert it to a string to keep the users choice in a
configuration file with some other options. How can I save it as a color
type to a table?
Thanks,
Henry
"RobinS" <Ro****@NoSpam.yah.nonewrote in message
news:4p******************************@comcast.com. ..
>Why do you want to convert it to a string?
If you're trying to save the setting so you can apply it
later when they run the app again, you can save it as a
color type.
Robin S.
-----------------------------
"Henry Jones" <he***@yada.comwrote in message
news:Ol**************@TK2MSFTNGP03.phx.gbl...
>>VB.NET Windows Forms VS 2005
I would like to give the user the option of changing the background
color of the textbox to anything they want. Can someone provide code
how to save the
textbox1.BackColor to a string and then convert it back to a color that
I can assign to the textbox?
I have looked at colorconverter class which can inherit from the
TypeConverter class and it's all too confusing. I tried some examples
and just can't get it.
I tried something like this:
Dim myColor As Color = Color.PaleVioletRed
' Create the ColorConverter.
Dim converter As System.ComponentModel.TypeConverter = _
System.ComponentModel.TypeDescriptor.GetConverter( myColor)
and it works if the color is already set, but what if I want the user to
choose from the Color Dialog box?
HELP please