?
Solved

System.Drawing.Color Converting to Integer?

Posted on 2009-04-07
8
Medium Priority
?
3,242 Views
Last Modified: 2013-12-26
I am using the colordialog to set the backcolor of a text box.
I use VB 2008 as the front end and MS Access as the backend.  
Can you convert the color to an integer or something that can be saved to the database and then easily set when the value is retrieved?
Please provide an example.  When I click on links my IE crashes.
Thanks
This is what I use to get the color... no idea on how to save it.
ColorDialog1.AllowFullOpen = True
        ColorDialog1.AnyColor = True
        ColorDialog1.SolidColorOnly = False
        ColorDialog1.ShowHelp = True
        If ColorDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.txtCarColor.BackColor = ColorDialog1.Color
            Me.txtCarColor.Text = ColorDialog1.Color.Name.ToString
        End If

Open in new window

0
Comment
Question by:Sheritlw
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
8 Comments
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085253
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085318
POC should do for you:
            colorDialog1.ShowDialog();
            Color mycolor = colorDialog1.Color;
            int valuetoDb = mycolor.ToArgb();
           
            //save valuetodb into db

            Color getColorfrom = Color.FromArgb(valuetoDb);
0
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 24085324
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24085326
VB version:
colorDialog1.ShowDialog()
Dim mycolor As Color = colorDialog1.Color
Dim valuetoDb As Integer = mycolor.ToArgb()

'save valuetodb into db

Dim getColorfrom As Color = Color.FromArgb(valuetoDb)
0
 

Author Comment

by:Sheritlw
ID: 24090293
How do I convert it back to the color from the integer?
0
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 400 total points
ID: 24091828
0
 
LVL 9

Expert Comment

by:Sreedhar Vengala
ID: 24092192
Its all there in :

POC should do for you:
            colorDialog1.ShowDialog();
            Color mycolor = colorDialog1.Color;
            int valuetoDb = mycolor.ToArgb();
           
            //save valuetodb into db
            //Convert back to color
            Color getColorfrom = Color.FromArgb(valuetoDb);
0
 
LVL 9

Accepted Solution

by:
Sreedhar Vengala earned 1600 total points
ID: 24092202
All there in (VB version)
VB version:
colorDialog1.ShowDialog()
Dim mycolor As Color = colorDialog1.Color
Dim valuetoDb As Integer = mycolor.ToArgb()

'save valuetodb into db
//Convert int back to color
Dim getColorfrom As Color = Color.FromArgb(valuetoDb)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month13 days, 16 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question