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

The exception that is thrown when one of the arguments provided to a method is not valid.

Hi,

My code:

kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;

but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.

transparent backgroundcolors not handled.

Dec 8 '07 #1
4 1774
Rinaldo <zw*************@hotmail.com.nospamwrote:
My code:

kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;

but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.

transparent backgroundcolors not handled.
Well, that seems fairly clear to me - you've provided a transparent
background colour, and the control doesn't support that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Dec 8 '07 #2
On Sat, 08 Dec 2007 09:15:06 -0800, Rinaldo
<zw*************@hotmail.com.nospamwrote:
Hi,

My code:

kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;

but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.

transparent backgroundcolors not handled.
As Jon says, the exception seems pretty clear.

As far as why you're getting the exception, note the name of the method
you're using to initialize the Color. FromArgb(). From==>A<==rgb().
Emphasis on "A". That's "alpha" and it means that it expects the number
you're passing into include an alpha component (i.e. transparency).

It seems likely that the color value you're reading is just as plain
24-bit color value, so the alpha is 0 (i.e. completely transparent).

You need to make sure you have a color with the alpha component set to 255
(i.e. completely opaque) before using it somewhere that transparent colors
aren't supported (like for background colors). IMHO, the easiest way to
do that is just use the FromArgb() overload that takes the alpha and color
separately:

Color kl = Color.FromArgb(255, Color.FromArgb(kleur));

Why there's no Color.FromArgb(Int32, Int32) so that you can avoid going
through the constructor twice, I don't know. But it shouldn't be a big
deal. This is unlikely to ever be a performance bottleneck.

Pete
Dec 8 '07 #3
Hi Pete,

English is not my motherlanguage, I do not understand all errors.
I saw that the color I was writing was always 0.
Unfornually, I leave it :(

Thanks for support.

"Peter Duniho" <Np*********@nnowslpianmk.comschreef in bericht
news:op***************@petes-computer.local...
On Sat, 08 Dec 2007 09:15:06 -0800, Rinaldo
<zw*************@hotmail.com.nospamwrote:
Hi,

My code:

kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;

but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.

transparent backgroundcolors not handled.
As Jon says, the exception seems pretty clear.

As far as why you're getting the exception, note the name of the method
you're using to initialize the Color. FromArgb(). From==>A<==rgb().
Emphasis on "A". That's "alpha" and it means that it expects the number
you're passing into include an alpha component (i.e. transparency).

It seems likely that the color value you're reading is just as plain
24-bit color value, so the alpha is 0 (i.e. completely transparent).

You need to make sure you have a color with the alpha component set to 255
(i.e. completely opaque) before using it somewhere that transparent colors
aren't supported (like for background colors). IMHO, the easiest way to
do that is just use the FromArgb() overload that takes the alpha and color
separately:

Color kl = Color.FromArgb(255, Color.FromArgb(kleur));

Why there's no Color.FromArgb(Int32, Int32) so that you can avoid going
through the constructor twice, I don't know. But it shouldn't be a big
deal. This is unlikely to ever be a performance bottleneck.

Pete

Dec 8 '07 #4
Rinaldo.

http://www.google.com/search?hl=en&q...Abobpowell.net

www.bobpowell.net

he has good examples and I googled and saw some "FromArgb"

I think if you look at some of his code (because he is very good) you can
figure out some stuff.

"Rinaldo" <zw*************@hotmail.com.nospamwrote in message
news:97**********************************@microsof t.com...
Hi,

My code:

kleur = binFavorietReader.ReadInt32();
Color kl = Color.FromArgb(kleur);
BackColor = kl;

but get an exeption: The exception that is thrown when one of the
arguments provided to a method is not valid.

transparent backgroundcolors not handled.

Dec 8 '07 #5

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

Similar topics

5
by: Fao, Sean | last post by:
I'm reading The C++ Programming Language by Bjarne Stroustrup and I was unclear as to the proper way to catch an exception thrown by the new keyword. I was wondering if someobody here could let me...
3
by: PB | last post by:
As part of an ASP.NET WEb Application I have a routine (relevant portion is below) that lets users rotate a photo (jpg or gif). The routine works just fine if it is run once. If run a second time...
2
by: Tyler Foreman | last post by:
Hello, I had an earlier post regarding a strange exception I (thought) I was getting in my windows form. I have since been able to trace the problem to a picturebox control on my form. I can...
6
by: Programador | last post by:
I'm getting this error when running this program: Cannot calculate rate using the arguments provided Module Module1 Sub Main() Rate(360, -694.44444444444446, 244274.69178082192) End Sub
1
by: R | last post by:
Hi All, I'm using PHP 5, my code fully separates code from content, my code throws exceptions (LIZException) when error occurs. but every time I throw exception I get this fatal error: ...
1
by: yancheng.cheok | last post by:
Hi all, According to "How can I handle a constructor that fails?" in http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.2, whenever there is a constructor fail, we will throw...
1
by: matt.arens | last post by:
here is some background: I am using the MQSeries/Websphere .Net classes provided by Microsoft. The Websphere Windows Client software is required in order to use the ..Net classes. However, I...
0
by: drop | last post by:
Hi, I have some DropDownLists that are contained in a DetailsView. Here's a sample of my code for the DropDownLists : <InsertItemTemplate> <asp:DropDownList ID="ddl_TourOp" runat="server"...
0
by: sethuraman | last post by:
Hi, I have had a problem before, I am not sure about the exact exception that is thrown.. but I am sure that there is an exception thrown after processing 600 and odd rows in a DB2 JDBC...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.