473,395 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Saving the Color value into a string

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
Nov 20 '06 #1
8 8669
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

Nov 20 '06 #2
me
Henry Jones wrote:
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
Use the common dialog for color full open style to select a color

for use of the color between runs, create registry entry for your
program under current user/software/programname/startup/textbox1color
etc... or create your own ini file.

save all settings before exit... load all on startup
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Nov 20 '06 #3
guy
Why a string?
just keep it as a color
or if you must there is always Color.ToString
or more sensibly
color.FromARGB / Color.ToARGB convert colours To/From integers
and if you ***really*** need it as a string use the above to get the integer
and then convert that to a string (although I cannot see the point)

Guy

"Henry Jones" wrote:
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
Nov 21 '06 #4
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


Nov 21 '06 #5
Thanks for the info, but how can I keep it as a color in a table? I will
look up the Color options you suggested.

Henry

"guy" <gu*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Why a string?
just keep it as a color
or if you must there is always Color.ToString
or more sensibly
color.FromARGB / Color.ToARGB convert colours To/From integers
and if you ***really*** need it as a string use the above to get the
integer
and then convert that to a string (although I cannot see the point)

Guy

"Henry Jones" wrote:
>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

Nov 21 '06 #6
I have a table with user options that is why I wanted to store the color
options as a string.
I thought if I converted the value to a string, it would be easy to convert
back. But no, it's not.

Thanks,

Henry

"me" <ge******@lisco.comwrote in message
news:11**************@sp6iad.superfeed.net...
Henry Jones wrote:
>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
Use the common dialog for color full open style to select a color

for use of the color between runs, create registry entry for your program
under current user/software/programname/startup/textbox1color etc... or
create your own ini file.

save all settings before exit... load all on startup
----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet
News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+
Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption
=----

Nov 21 '06 #7

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



Nov 21 '06 #8
guy
convert it to an integer using FromARGB and ToARGB

hth

guy

"Henry Jones" wrote:
Thanks for the info, but how can I keep it as a color in a table? I will
look up the Color options you suggested.

Henry

"guy" <gu*@discussions.microsoft.comwrote in message
news:15**********************************@microsof t.com...
Why a string?
just keep it as a color
or if you must there is always Color.ToString
or more sensibly
color.FromARGB / Color.ToARGB convert colours To/From integers
and if you ***really*** need it as a string use the above to get the
integer
and then convert that to a string (although I cannot see the point)

Guy

"Henry Jones" wrote:
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


Nov 21 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: mchl gdbt | last post by:
Hi, I have several thousand tiffs generated by application A which are read by application B. I need to remove a few colours from the tiffs and I decided to try with the python imaging library....
7
by: G-Factor | last post by:
Hi all I've just started learning about saving files. I got bit of a problem. The following code gives me an error about incompatible types. (Cannot covert from class character to char *). I...
3
by: Brenny | last post by:
Hello I'm developing a project by using access database and there is a table(Table1) and it has a field(ml_mik) this is the decimal field. I'm taking a value from windows form as a decimal...
4
by: dale zhang | last post by:
Hi, I am trying to save and read an image from MS Access DB based on the following article: http://www.vbdotnetheaven.com/Code/Sept2003/2175.asp Right now, I saved images without any...
3
by: andy_ro | last post by:
Hi group, I have an web application where the user can upload a pdf file. This file is stored in a table, in a column of type ntext. The user can later request the content of this column, and...
2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
4
by: Daves | last post by:
I am saving to database a result from multi-line textbox. The database of course wants \x escape codes, not the invisible ones. Is there any easy - one line code - way to do this (c#) eg by...
18
by: TORQUE | last post by:
Hi, Im wondering if anyone can help me with a problem. I have a form with more than 50 unbound fields. Some of the fields will be blank from time to time. This seems to be where im having...
6
by: Jeff | last post by:
Hey (and thank you for reading my post) In visual web developer 2005 express edition I've created a simple website project.. At this website I want users who register to be able to upload a...
5
by: jc | last post by:
RE: Two Classes with the same Data Structure.. saving code? Inheriting a structure? I have two classes. One in Inherits System.Collections.CollectionBase, the other does not, but they both have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.