Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Any way to get the hex code of the color from the ColorDialog?

 

My code:

codebox.SelectedText = "<font color='" + ColorDialog.Color + "'>" + codebox.SelectedText + "</font>"

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Posted

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. :)

Here's what I'm up to.
Posted
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

Page Edit 2.0 Alpha 2 OUT NOW!

- Download Now -

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...