Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Apr 07, 2008 02:13 PM by SGWellens
Participant
1393 Points
346 Posts
Apr 07, 2008 12:17 AM|LINK
hi i m building a wpf application and i m trying to convert a hex color to an rgb color how can i do it?
thx in advance
1164 Points
227 Posts
Apr 07, 2008 01:55 AM|LINK
Hi,
Following link would be helpful to you
http://www.freevbcode.com/ShowCode.asp?ID=6324
Mark as Answer, if you find this helpful
All-Star
126031 Points
10310 Posts
Moderator
Apr 07, 2008 02:01 AM|LINK
Like this:
private void button1_Click(object sender, RoutedEventArgs e) { // Add reference: System.Drawing System.Drawing.Color MyColor = System.Drawing.Color.FromArgb(0xFF0000); }
Apr 07, 2008 02:00 PM|LINK
SGWellens Like this: private void button1_Click(object sender, RoutedEventArgs e) { // Add reference: System.Drawing System.Drawing.Color MyColor = System.Drawing.Color.FromArgb(0xFF0000); }
looks great but how can i get it to work i have the value on a textbox
Apr 07, 2008 02:13 PM|LINK
You must first convert the text in the text box to an integer type...something like this:
int ColorAsInt; ColorAsInt = int.Parse(TextBox11.Text, NumberStyles.HexNumber);
You should add exception handling in case the user enters "garbage" in the textbox.
yassir.2
Participant
1393 Points
346 Posts
Hex-to-RGB Conversion
Apr 07, 2008 12:17 AM|LINK
hi i m building a wpf application and i m trying to convert a hex color to an rgb color how can i do it?
thx in advance
pnv.ravikira...
Participant
1164 Points
227 Posts
Re: Hex-to-RGB Conversion
Apr 07, 2008 01:55 AM|LINK
Hi,
Following link would be helpful to you
http://www.freevbcode.com/ShowCode.asp?ID=6324
Mark as Answer, if you find this helpful
Happy coding..
-------------------------------------------------------------------
Please mark as answer if you find this post helpful.
SGWellens
All-Star
126031 Points
10310 Posts
Moderator
Re: Hex-to-RGB Conversion
Apr 07, 2008 02:01 AM|LINK
Like this:
private void button1_Click(object sender, RoutedEventArgs e) { // Add reference: System.Drawing System.Drawing.Color MyColor = System.Drawing.Color.FromArgb(0xFF0000); }My blog
yassir.2
Participant
1393 Points
346 Posts
Re: Hex-to-RGB Conversion
Apr 07, 2008 02:00 PM|LINK
looks great but how can i get it to work i have the value on a textbox
SGWellens
All-Star
126031 Points
10310 Posts
Moderator
Re: Hex-to-RGB Conversion
Apr 07, 2008 02:13 PM|LINK
You must first convert the text in the text box to an integer type...something like this:
int ColorAsInt; ColorAsInt = int.Parse(TextBox11.Text, NumberStyles.HexNumber);You should add exception handling in case the user enters "garbage" in the textbox.
My blog