473,606 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.BackCo lor 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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 8694
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.com wrote in message
news:Ol******** ******@TK2MSFTN GP03.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.BackCo lor 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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.BackCo lor 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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.BackCo lor 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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.com wrote in message
news:Ol******** ******@TK2MSFTN GP03.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.BackC olor 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
TypeConverte r 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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*@discussion s.microsoft.com wrote in message
news:15******** *************** ***********@mic rosoft.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.BackC olor 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
TypeConverte r 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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.s uperfeed.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.BackC olor 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
TypeConverte r 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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 ProductTextBoxC olor,
CustomerTextBox Color, 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.Pro ductTextBoxColo r = Color.PaleViole tRed

Then when you want to use it, use My.Settings.Pro ductTextBoxColo r
instead of a color. It will retrieve the value from the Settings
and use it.

ProductTextBox. BackColor = My.Settings.Pro ductTextBoxColo r

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.Pro ductTextBoxColo r;
this way you can ensure that it's working properly.

Robin S.

"Henry Jones" <he***@yada.com wrote in message
news:eM******** ******@TK2MSFTN GP06.phx.gbl...
>I wanted to convert it to a string to keep the users choice in a
configuratio n 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.com wrote in message
news:Ol******* *******@TK2MSFT NGP03.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.Back Color 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
TypeConvert er 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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*@discussion s.microsoft.com wrote in message
news:15******** *************** ***********@mic rosoft.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.BackCo lor 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.PaleViole tRed

' Create the ColorConverter.
Dim converter As System.Componen tModel.TypeConv erter = _
System.Componen tModel.TypeDesc riptor.GetConve rter(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
2184
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. Running under debug mode permits saving my tiff files (with Image.DEBUG=0, the save doesn't work! see below) , but it truncates the crazy tags in my tiff and changes the resolution of the image
7
7519
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 would appreciate it if anyone could either help me out, or direct me to an online resource site that has information on saving/loading classes. I have found several tutorials, but they either do not really help (saving text files) or are too...
3
6504
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 variable(for example 12,3 or 12.3). After saving record, value(12,3 or 12.3) is saved as 123, not 12,3 or 12.3... I'm using ADO.NET for processes in the database.
4
3284
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 errors. After reading the ole object from db, I saved it to C: as file1.bmp and displayed on the web. But it can not be displayed. After I manually sent the file to wordpad, it shows
3
16251
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 the application should open a new page and load the pdf content. My problem: If I read the uploaded pdf file into a string variable and then I response.write it right away to another page, it shows fine (I can see a pdf
2
3184
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 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/creatingcustomcolumns.asp The problem I am having is that the data in the custom datagridcolumn is not saved to viewstate and after postback, the column does not contain data.
4
1476
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 String.Format() ?
18
3780
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 trouble. I have tried keeping some of the fields bound and when I use the save button it has been saving as 2 different records. This is unacceptable. This is what I have, can anyone help me out with this?
6
8110
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 picture of themselves to their profile... I admit that I'm a newbie... but this is how I understand this:
5
1549
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 the identical structure and properties. the only difference between them is there methods and that one is a collection class and the other is not. currently the code starts like this:
0
8009
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7939
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8432
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8428
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
5962
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3919
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2442
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1548
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1285
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.