473,395 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How To Casting/Convert Color

Hi Everyone,

Is there a way (syntax) for converting/casting color so I can find the
System.Byte of my chosen color with in my button?

I have buttons colored ie "Color.Olive" and up to now I change the color
into another color. But what I want to do at run time is to find the
existing color say in FromArgb and just darken the existing color at run
time.

Any and all help is appreciated.

MikeY
Apr 6 '06 #1
5 2185
I ment to add C# Windows Forms

MikeY

"MikeY" <mi*******@yaho.com> wrote in message
news:%e*******************@news20.bellglobal.com.. .
Hi Everyone,

Is there a way (syntax) for converting/casting color so I can find the
System.Byte of my chosen color with in my button?

I have buttons colored ie "Color.Olive" and up to now I change the color
into another color. But what I want to do at run time is to find the
existing color say in FromArgb and just darken the existing color at run
time.

Any and all help is appreciated.

MikeY

Apr 6 '06 #2
MikeY,

The control should expose a Color instance for the background of your
button. Why not just get that and then set the A, R, G, and B properties to
the values you want. Then, you should be able to set the value back on the
control.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"MikeY" <mi*******@yaho.com> wrote in message
news:%e*******************@news20.bellglobal.com.. .
Hi Everyone,

Is there a way (syntax) for converting/casting color so I can find the
System.Byte of my chosen color with in my button?

I have buttons colored ie "Color.Olive" and up to now I change the color
into another color. But what I want to do at run time is to find the
existing color say in FromArgb and just darken the existing color at run
time.

Any and all help is appreciated.

MikeY

Apr 6 '06 #3
Hi Nicholas,

Normally I would, but I'm working with custom buttons and if I or the user
inputs a color for the button at run-time then I would like the change the
color scheme upon button click from say the initial
Color.FromArgb(((System.Byte)(64)),
((System.Byte)(64)),((System.Byte)(64))); to
Color.FromArgb(((System.Byte)(70)),
((System.Byte)(70)),((System.Byte)(70))); But the color palate is going to
be ie "Color.Olive" and I would like to change it to a Darker Olive color.
So the only way I can figure doing this is to convert the color to Argb then
add + 10 to the bytes. If that makes sense in what I'm trying to say.

Thanks for your replay

MikeY

"MikeY" <mi*******@yaho.com> wrote in message
news:%e*******************@news20.bellglobal.com.. .
Hi Everyone,

Is there a way (syntax) for converting/casting color so I can find the
System.Byte of my chosen color with in my button?

I have buttons colored ie "Color.Olive" and up to now I change the color
into another color. But what I want to do at run time is to find the
existing color say in FromArgb and just darken the existing color at run
time.

Any and all help is appreciated.

MikeY

Apr 6 '06 #4
MikeY wrote:
[darkening colours]


The ControlPaint.Dark method can do this by a fixed amount (the same
amount by which a button shadow is darker than its front face).

Eq.
Apr 6 '06 #5
Thank you Paul. This is exactly what I am looking for

MikeY

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:h6********************@bt.com...
MikeY wrote:
[darkening colours]


The ControlPaint.Dark method can do this by a fixed amount (the same
amount by which a button shadow is darker than its front face).

Eq.

Apr 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
2
by: Frazer | last post by:
hi, I am confused when to use (int) and when to use Convert.toint32.. eg here string s= "1"; int j = (int) s; //this gives me an error and i have to use convert.toint32. why is that so and...
7
by: yufufi | last post by:
lets say we have a 'shape' class which doesn't implement IComparable interface.. compiler doesn't give you error for the lines below.. shape b= new shape(); IComparable h; h=(IComparable)b;...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
61
by: Ken Allen | last post by:
I am relatively new to .Net, but have been using VB and C/C++ for years. One of the drawbacks with VB6 and earlier was the difficulty in casting a 'record' to a different 'shape' so one could...
23
by: René Nordby | last post by:
Hi there, Is there anyone that knows how to do the following? I have a class A and a class B, that 100% inherits from class A (this means that I don't have other code in class B, than...
12
by: 6tc1 | last post by:
Hi all, I just discovered a rounding error that occurs in C#. I'm sure this is an old issue, but it is new to me and resulted in a fair amount of time trying to track down the issue. Basically...
8
by: Herby | last post by:
Given class B and C which inherit from class A They all override a method of the form: Add( A^ lhs, A^ rhs ); So A is abstract. So if i was defining Add for class B : B::Add( A^ lhs, A^ rhs...
6
by: Ken Fine | last post by:
This is a basic question. What is the difference between casting and using the Convert.ToXXX methods, from the standpoint of the compiler, in terms of performance, and in other ways? e.g. ...
32
by: alex.j.k2 | last post by:
Hello all, I have "PRECISION" defined in the preprocessor code and it could be int, float or double, but I do not know in the code what it is. Now if I want to assign zero to a "PRECISION"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.