colordialog.color to int

  • Thread starter Thread starter Rinaldo
  • Start date Start date
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.
 
Hi Rinaldo

You have mixed FromArgh with ToArgb

Color redColor = Color.FromName("Red");
int redValue = redColor.ToArgb();
Color newRedColor = Color.FromArgb(redValue);
 
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.
 
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
 
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()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top