Click here to Skip to main content
15,901,373 members
Home / Discussions / C#
   

C#

 
GeneralRe: Another Async Question Pin
Kevin Marois8-Apr-15 8:30
professionalKevin Marois8-Apr-15 8:30 
GeneralRe: Another Async Question Pin
Mycroft Holmes8-Apr-15 14:22
professionalMycroft Holmes8-Apr-15 14:22 
Question{0} Pin
Member 115906308-Apr-15 3:04
Member 115906308-Apr-15 3:04 
AnswerRe: {0} Pin
harold aptroot8-Apr-15 3:35
harold aptroot8-Apr-15 3:35 
AnswerRe: {0} Pin
Sascha Lefèvre8-Apr-15 3:49
professionalSascha Lefèvre8-Apr-15 3:49 
Questionconverting given hex value into rgb Pin
Member 115353748-Apr-15 1:25
Member 115353748-Apr-15 1:25 
GeneralRe: converting given hex value into rgb Pin
harold aptroot8-Apr-15 1:44
harold aptroot8-Apr-15 1:44 
AnswerRe: converting given hex value into rgb Pin
OriginalGriff8-Apr-15 4:38
mveOriginalGriff8-Apr-15 4:38 
That depends on exactly what you want to show!
A "hex number" is technically an RGB code already, but that isn't too useful.
So start by converting it to a Color:
C#
public Color FromHex(string hex)
   {
   if (!hex.StartsWith("#")) hex = "#" + hex;
   return ColorTranslator.FromHtml(hex);
   }

Now you can use the colour to set the Text color of the new textbox:
C#
displayTextBox.ForeColor = FromHex(hexTextBox.Text);

Or show what colour it is:
C#
displayTextBox.Text = FromHex(hexTextBox.Text).ToString();

Or it's RGB values:
C#
Color c = FromHex(hexTextBox.Text);
displayTextBox.Text = string.Format("{0}:{1}:{2}", c.R, c.G, c.B);



[edit]"ForColor" changed to "ForeColor" - Thanks Richard![/edit]
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...


modified 8-Apr-15 14:17pm.

JokeRe: converting given hex value into rgb Pin
Richard Deeming8-Apr-15 8:04
mveRichard Deeming8-Apr-15 8:04 
GeneralRe: converting given hex value into rgb Pin
OriginalGriff8-Apr-15 8:17
mveOriginalGriff8-Apr-15 8:17 
Questionsharing files on single pc in .net Pin
Member 115353748-Apr-15 1:23
Member 115353748-Apr-15 1:23 
QuestionRe: sharing files on single pc in .net Pin
Richard MacCutchan8-Apr-15 2:41
mveRichard MacCutchan8-Apr-15 2:41 
AnswerRe: sharing files on single pc in .net Pin
User 418025417-Jul-15 9:54
User 418025417-Jul-15 9:54 
Questioncode for androide xml analyser Pin
Member 115824057-Apr-15 22:29
Member 115824057-Apr-15 22:29 
QuestionRe: code for androide xml analyser Pin
Stefto7-Apr-15 22:56
professionalStefto7-Apr-15 22:56 
AnswerRe: code for androide xml analyser Pin
Simon_Whale7-Apr-15 23:19
Simon_Whale7-Apr-15 23:19 
QuestionAudio Visualisation For RGB STRIP Via C# Pin
Marek Gamelaster Kraus7-Apr-15 9:00
Marek Gamelaster Kraus7-Apr-15 9:00 
AnswerRe: Audio Visualisation For RGB STRIP Via C# Pin
V.7-Apr-15 20:03
professionalV.7-Apr-15 20:03 
GeneralRe: Audio Visualisation For RGB STRIP Via C# Pin
Marek Gamelaster Kraus8-Apr-15 3:11
Marek Gamelaster Kraus8-Apr-15 3:11 
QuestionEmpty path name is not legal - image upload Pin
DPaul19947-Apr-15 6:49
DPaul19947-Apr-15 6:49 
AnswerRe: Empty path name is not legal - image upload Pin
Eddy Vluggen7-Apr-15 8:03
professionalEddy Vluggen7-Apr-15 8:03 
AnswerRe: Empty path name is not legal - image upload Pin
OriginalGriff7-Apr-15 8:05
mveOriginalGriff7-Apr-15 8:05 
GeneralRe: Empty path name is not legal - image upload Pin
DPaul19947-Apr-15 8:49
DPaul19947-Apr-15 8:49 
GeneralRe: Empty path name is not legal - image upload Pin
OriginalGriff8-Apr-15 0:18
mveOriginalGriff8-Apr-15 0:18 
GeneralRe: Empty path name is not legal - image upload Pin
DPaul19949-Apr-15 4:09
DPaul19949-Apr-15 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.