[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SET COLOR AND FIND COLOR FROM NUMBER

Posted on 2012-09-10
8
Medium Priority
?
490 Views
Last Modified: 2012-09-10
Hi All,

I want to set color.

1. Using Number
2. Using Color equivalent to color number.

For example :

Say, I want to set color to "192, 192, 255" :

1. How to set it using color number.
2. What is the equivalent color >

 .AlternatingRowsDefaultCellStyle.BackColor = color number
 .AlternatingRowsDefaultCellStyle.BackColor = color......

Thank you.
0
Comment
Question by:emi_sastra
  • 5
  • 3
8 Comments
 
LVL 10

Accepted Solution

by:
honestman31 earned 2000 total points
ID: 38382585
please see this
http://forum.codecall.net/topic/51797-colors-in-vbnet/



     Dim C As Color

        C = Color.FromArgb(30, 155, 0, 144)

        C = Color.FromArgb(255, 255, 0)

        C = Color.FromArgb(0, 0, 0)
0
 
LVL 10

Expert Comment

by:honestman31
ID: 38382600
Try this

 .AlternatingRowsDefaultCellStyle.BackColor=color.FromArgb(255, 255, 0)


 .AlternatingRowsDefaultCellStyle.BackColor= Color.Beige



------------
2. What is the equivalent color > Not every number has equivalent color name

You can use a site like this
http://www.pangloss.com/seidel/ClrHlpr/mixer.html
to know how is the color looks like
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38382802
Hi honestman31,

Could I know color.FromArgb(255, 255, 0) = what color ? For example = Color.Beige

Thank you.
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 10

Expert Comment

by:honestman31
ID: 38382850
(255, 255, 0) --> Yellow

go to http://www.pangloss.com/seidel/ClrHlpr/mixer.html   enter  the numbers then hit enter  , you will see it is yellow
0
 
LVL 10

Expert Comment

by:honestman31
ID: 38382860
there is another one you can use ( You can see the color name )
http://www.keller.com/html-quickref/4a.html

FFFF00
yellow

FF = 255
FF=255
00=0
So  ( 255, 255, 0)   = FFFF00   ( Means Yellow )
0
 
LVL 1

Author Comment

by:emi_sastra
ID: 38382875
Thank you for the link.

I just wonder, could I do it using vb code to generate color name from number ?

Thank you.
0
 
LVL 10

Expert Comment

by:honestman31
ID: 38382940
There is an example about that  here
http://msdn.microsoft.com/en-us/library/system.drawing.color.fromname.aspx#Y240

But As I said before not every color number can  have a color name
Private Sub ShowPropertiesOfSlateBlue(ByVal e As PaintEventArgs)
    Dim slateBlue As Color = Color.FromName("SlateBlue")
    Dim g As Byte = slateBlue.G
    Dim b As Byte = slateBlue.B
    Dim r As Byte = slateBlue.R
    Dim a As Byte = slateBlue.A
    Dim text As String = _
    String.Format("Slate Blue has these ARGB values: Alpha:{0}, " _
       & "red:{1}, green: {2}, blue {3}", New Object() {a, r, g, b})
    e.Graphics.DrawString(text, New Font(Me.Font, FontStyle.Italic), _
        New SolidBrush(slateBlue), _
        New RectangleF(New PointF(0.0F, 0.0F), _
        Size.op_Implicit(Me.Size)))
End Sub

Open in new window

0
 
LVL 1

Author Closing Comment

by:emi_sastra
ID: 38382974
Ok.

Thank you very much for your help.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

834 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