Getox Posted September 15, 2005 Posted September 15, 2005 Any way to get the hex code of the color from the ColorDialog? My code: codebox.SelectedText = "<font color='" + ColorDialog.Color + "'>" + codebox.SelectedText + "</font>" Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Machaira Posted September 15, 2005 Posted September 15, 2005 Try: codebox.SelectedText = "<font color='" + ColorDialog.Color.ToKnownColor.ToString + "'>" + codebox.SelectedText + "</font>" The only problem is if the user selects a funky color, you'll get a "0". There's probably a solution for that though. :) Quote Here's what I'm up to.
Getox Posted September 15, 2005 Author Posted September 15, 2005 Thanks, Now How would i get the Hex code for it and allow them to choose any color? Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Administrators PlausiblyDamp Posted September 15, 2005 Administrators Posted September 15, 2005 Scrappy as hell ;) put seemed to work Color.Red.ToArgb().ToString("X").Substring(2); I really, really hope there is a better and cleaner way than that though ;) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Getox Posted September 15, 2005 Author Posted September 15, 2005 Scrappy as hell ;) put seemed to work Color.Red.ToArgb().ToString("X").Substring(2); I really, really hope there is a better and cleaner way than that though ;) Do i have to do that for every color? Here is my new code: Dim text As String FontDialog.ShowColor = True If FontDialog.ShowDialog() = DialogResult.OK Then text = "<font style='font-size:" + FontDialog.Font.Size.ToString + "px;' face='" + FontDialog.Font.FontFamily.Name + "' color='" + FontDialog.Color.ToKnownColor.ToString + "'>" + codebox.SelectedText + "</font>" If FontDialog.Font.Underline = True Then text = "<u>" + text + "</u>" End If If FontDialog.Font.Italic = True Then text = "<i>" + text + "</i>" End If If FontDialog.Font.Bold = True Then text = "<strong>" + text + "</strong>" End If If FontDialog.Font.Strikeout = True Then text = "<s>" + text + "</s>" End If codebox.SelectedText = text End If Quote Page Edit 2.0 Alpha 2 OUT NOW! - Download Now -
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.