Is there a way to add custom color?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello all,
I'm sure there is, just can't figure it out. I have the RGB code and the
color number. But the color doesn't exsist in Visual studio.net. Can I add
this color to the system pallet it self, so I can add the custom color to
fonts? I need to match as close as possible to the color I was given. Thanks

Rudy
 
I may be wrong but I don't think that it's easily possible to get the color
to be available across GUI element Property Sheets . You can define a color
using the "Custom" tab of a specific GUI elements' XXXcolor property but
that custom color is only for that element and that XXXcolor property so in
my experience you won't see it in the Custom tab of any other GUI elements
or even other XXXcolor properties of the same element. For example, setting
a custom BackColor property using the property page won't put that custom
color in the ForeColor property's color picker . To see this, select the
"Custom" tab in any color property such as "BackColor" and right click on
one of the empty squares at the bottom of the picker, this will pop up a
color designer where you can type in the rbg values. Now look at the same
elements's Forecolor Custom tab and you see that the color is not there.

However, it's easily done with a bit of code.

Create a new winform project. Add two buttons.

In the button1 click type:

Dim c As New Color
Me.BackColor = c.FromArgb(34, 45, 56)

Run the program and click the button.


Now, add the following to the declaration section (module level private var)
Private m_MySpecialColor As Color = Color.FromArgb(90, 100, 200)

And in the button2 click event type:
Me.BackColor = m_MySpecialColor

Run the program and press button 2.

You can use this color in your labels and strings of any control by setting
each controls' Forecolor property in code (perhaps in an formInit function
called by the form_load). Or, if you are defining Font objects explicity
you can use the color.FromArgb(x,y,z) right in the Font constructor (if the
color object is set in an accessable variable as shown in the second example
above, then you just reference that Color in the Font constructor).


Note: I used to work for an artist who took his colors VERY seriously and I
remember sitting with him and getting a color to be exactly as he wanted on
one machine. He was happy. Then he ran the app on another machine and it
was off... you can only get so close when it comes right down to it because
every video card and monitor will make your color look slightly different.


Robert Smith
Kirkland, WA
www.smithvoice.com
 
Thanks Rob!

A great suggestion! I 'll give it a shot. I use to work in television
production, so I'm very aware how important color is in video, even in a
computer monitor. I also now how nearly impossible you can match colors on
monitors. On TV production monitors, you have a blue gun button, that you can
only see the blues, and match to SMTE Color bars, with that you make monitors
match exactly, as long the monitor is in good working order. But with
computer monitors, good luck! I have even bought two high quality monitors,
exact same model, at the same time, and still not be able to get a match.
But I figure if I can tell the client, "I used your numbers.", I pretty much
done all that I can. Thanks again for you time

Rudy
 
That is funny, not too many that I have met that went from television to
programming. My first programming .net metting I went to, I felt so out of
place. I was the only one in a room of about thirty people who was wearing
jeans and a flannel, with a toolkit on my belt. I went there right from a
shoot. Talk about not fitting in. LOL By the way, I did try your idea,
works like a charm. Thanks. I just have to decide if this client is worth it.

Rudy
 
Back
Top