473,387 Members | 1,353 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,387 software developers and data experts.

colordialog.color to int

How to cast colordialog,color to a int (or long) ?
Dec 7 '07 #1
7 10497
Rinaldo wrote:
How to cast colordialog,color to a int (or long) ?
Call its .ToArgb() method.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Dec 7 '07 #2
I get an error:
Error 1 No overload for method 'ToArgb' takes '1' arguments

on the line:

Color kl = Color.ToArgb(BackColor);

What is wrong?

When I do not have an argument then he needs 1 argument.

"Lasse Vågsæther Karlsen" <la***@vkarlsen.noschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
Rinaldo wrote:
>How to cast colordialog,color to a int (or long) ?

Call its .ToArgb() method.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/
Dec 7 '07 #3
Hi Rinaldo

You have mixed FromArgh with ToArgb

Color redColor = Color.FromName("Red");
int redValue = redColor.ToArgb();
Color newRedColor = Color.FromArgb(redValue);
On Fri, 07 Dec 2007 16:37:19 +0100, Rinaldo <zw*************@hotmail.com.nospamwrote:
I get an error:
Error 1 No overload for method 'ToArgb' takes '1' arguments

on the line:

Color kl = Color.ToArgb(BackColor);

What is wrong?

When I do not have an argument then he needs 1 argument.

"Lasse Vågsæther Karlsen" <la***@vkarlsen.noschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
>Rinaldo wrote:
>>How to cast colordialog,color to a int (or long) ?

Call its .ToArgb() method.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/



--
Happy coding!
Morten Wennevik [C# MVP]
Dec 7 '07 #4
If you are using CustomColors, be careful - IIRC it uses BGR, not
ARGB... so you may need to move the bytes around or parse manually:

http://groups.google.co.uk/group/mic...22de22067a49c1

Marc
Dec 7 '07 #5
Hi Morten,

I have:

Color kl = BackColor;
kleur = Color.ToArgb(kl);
binFavorietWriter.Write(kleur);

But does'nt work. I need to have the backcolor of the dialog to int and
write it to disk. (I ám a beginner)

Thanks.

"Morten Wennevik [C# MVP]" <Mo************@hotmail.comschreef in bericht
news:op.t2y5snebdj93y5@ubuan...
Hi Rinaldo

You have mixed FromArgh with ToArgb

Color redColor = Color.FromName("Red");
int redValue = redColor.ToArgb();
Color newRedColor = Color.FromArgb(redValue);
On Fri, 07 Dec 2007 16:37:19 +0100, Rinaldo
<zw*************@hotmail.com.nospamwrote:
>I get an error:
Error 1 No overload for method 'ToArgb' takes '1' arguments

on the line:

Color kl = Color.ToArgb(BackColor);

What is wrong?

When I do not have an argument then he needs 1 argument.

"Lasse Vågsæther Karlsen" <la***@vkarlsen.noschreef in bericht
news:%2****************@TK2MSFTNGP06.phx.gbl...
>>Rinaldo wrote:
How to cast colordialog,color to a int (or long) ?

Call its .ToArgb() method.

--
Lasse Vågsæther Karlsen
mailto:la***@vkarlsen.no
http://presentationmode.blogspot.com/


--
Happy coding!
Morten Wennevik [C# MVP]
Dec 8 '07 #6
On Sat, 08 Dec 2007 08:49:30 -0800, Rinaldo
<zw*************@hotmail.com.nospamwrote:
"Morten Wennevik [C# MVP]" <Mo************@hotmail.comschreef in
bericht news:op.t2y5snebdj93y5@ubuan...
>>
You have mixed FromArgh with ToArgb

Color redColor = Color.FromName("Red");
int redValue = redColor.ToArgb();
Color newRedColor = Color.FromArgb(redValue);

I have:

Color kl = BackColor;
kleur = Color.ToArgb(kl);
binFavorietWriter.Write(kleur);

But does'nt work. I need to have the backcolor of the dialog to int and
write it to disk. (I ám a beginner)
And what doesn't work? I mean, I know the answer but really...you need to
get into the habit of reading and understanding the compiler errors. You
also need to post specific error messages when asking questions about
them, not just write "but doesn't work".

As for this specific problem, look more closely at Morten's code. Copy
and paste it into your application if you have to. There's a very
specific difference between what he wrote, and what you managed to type in
to your own code. It's a critical difference, and I'm sure the compiler
is doing a decent job explaining it to you.

Pete
Dec 8 '07 #7
On Sat, 08 Dec 2007 17:49:30 +0100, Rinaldo <zw*************@hotmail.com..nospamwrote:
Hi Morten,

I have:

Color kl = BackColor;
kleur = Color.ToArgb(kl);
binFavorietWriter.Write(kleur);
ToArgb() is not a static method so you can't use Color.ToArgb(), nor does it take a parameter so Color.ToArgb(kl) is wrong in two ways. You need to call ToArgb() on an instance of Color, and since kl is such an instance try kl.ToArgb()

--
Happy coding!
Morten Wennevik [C# MVP]
Dec 10 '07 #8

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

Similar topics

1
by: Ekey | last post by:
Hi: I want to realize the function that get a transparent color with standard ColorDialog ,but standard ColorDialog is not transparent color.i do not want to define a dialog such as colordialog by...
2
by: SpotNet | last post by:
Hi Newsgroup, I've been creating (almost done) Common Dialog class libraries (under one name space) with highly customisable common dialogs. With my ColorDialog I am able to completely hide...
1
by: Pierre | last post by:
Hi, Allowing my User to set Excel charts colors in my app with the help of a ColorDialog, I'm facing the following problem : the ColorDialog Colors does not suit with the Excel ones. So, here...
0
by: Steve Randall | last post by:
If you enable the 'define custom colors' button on the ColorDialog control the displayed form displays the basic colors on the left-hand side and the 'color builder' on the right-hand side. ...
1
by: Steve Randall | last post by:
If I use the standard ColorDialog control to select a colour (say a pale blue) I get the returned value of 16762980 which is fine (Red=100, Green=200, Blue=255), BUT why when I use the following do I...
2
by: jcrouse | last post by:
I am trying to control the default color that is selected the first time my applciation is run and the color dialog box launches. I have a Tools/Options menu item in my application. On the Options...
0
by: ThunderMusic | last post by:
Hi, problem #1 : I have a MenuStrip on my Windows form and it doesn't get painted (is transparent) unless I move the form... Anyone ever encountered this? Anyone knows what could cause it? ...
1
by: nanaalwi | last post by:
Hi all, I'm doing a software using vb.net that related to excel. The software that i implement requires filling the color inside the cells. Previously, the source code that I used is: ...
4
by: MickT | last post by:
On an Options form I am setting a textbox.backcolor to a colour selected from the colordialog control, so that the backcolor of all textboxes in an application may be set to the user's preference. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.