Solved

System.Drawing.Color Converting to Integer?

Posted on 2009-04-07
8
2,808 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
  • 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
 
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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 100 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 400 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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now