Click here to Skip to main content
13,836,413 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


12 bookmarked
Posted 3 Mar 2008
Licenced CPOL

HEX and HTML Color Clipboard

, 3 Mar 2008
Rate this:
Please Sign up or sign in to vote.
This application is a HEX and HTML color clipboard


ColorCoder2 is the second version of my HEX & HTML Color wizard.
It is particularly useful in the Web and graphics design industry because it makes light work of RGB, HEX and HTML color codes. It also features an integrated clipboard manager that can store and monitor your clipboard entries as well as convert the color entry on-the-fly.

ColorCoder2 makes use of the Desktop Color Picker Application by Code Project User nd1279.

Using the Code

The code is formatted into different blocks of functions.

The following block converts the RGB colour values to hex and sets the control values:

/// <span class="code-SummaryComment"><summary></span>
/// Sets the color from hex
/// <span class="code-SummaryComment"></summary></span>
/// <span class="code-SummaryComment"><param name="hexValue">The Color value in Hex</param></span>
private void changeColor(string hexValue)
    colorLabel.Text = "";
        int tmpRed = 0;
        int tmpGreen = 0;
        int tmpBlue = 0;

        tmpRed = Convert.ToInt32(hexValue.Substring(0, 2), 16);
        if (hexValue.Length >= 4)
            tmpGreen = Convert.ToInt32(hexValue.Substring(2, 2), 16);
            if (hexValue.Length >= 6)
                tmpBlue = Convert.ToInt32(hexValue.Substring(4, 2), 16);
        //Set the Color Label
        colorLabel.BackColor = Color.FromArgb(255, tmpRed, tmpGreen, tmpBlue);
        //Set the Selectors
        redSelector.Value = tmpRed;
        redLbl.Text = tmpRed.ToString();
        redValue = tmpRed;
        greenSelector.Value = tmpGreen;
        greenLbl.Text = tmpGreen.ToString();
        greenValue = tmpGreen;
        blueSelector.Value = tmpBlue;
        blueLbl.Text = tmpBlue.ToString();
        blueValue = tmpBlue;
        //Set the HEX text box
        hexTxt.Text = hexValue;
        //Set the HTML text box
        htmlTxt.Text = "#" + hexValue;
        //Set the RGB text box
        rgbTxt.Text = "" + tmpRed + "," + tmpGreen + "," + tmpBlue;
        colorLabel.Text = hexTxt.Text;
    catch (Exception ex)
        colorLabel.BackColor = Color.White;
        colorLabel.Text = "Invalid Format";

Points of Interest

This application also makes use of the process class that monitors an external application and sets some values if the application is terminated.


  • 3rd March, 2008: Initial post
    Since this is version 2 and I never posted version 1, it is as up-to-date as it can be.
    Any suggestions and addons are welcome.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Pieter Alec Myburgh
Software Developer (Senior) EOH Microsoft Coastal
South Africa South Africa
Senior Software Engineer & Team Lead.

I reject your code and substitute my own!

You may also be interested in...

Comments and Discussions

GeneralBug Pin
Dan Danz30-Mar-08 3:10
memberDan Danz30-Mar-08 3:10 
GeneralRe: Bug Pin
eRRaTuM15-May-09 15:56
membereRRaTuM15-May-09 15:56 
GeneralColorCoder2 Upgrades Pin
Pieter Alec Myburgh5-Mar-08 4:06
memberPieter Alec Myburgh5-Mar-08 4:06 
GeneralNice utility Pin
iLeKtraN4-Mar-08 9:04
memberiLeKtraN4-Mar-08 9:04 

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.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web03 | 2.8.190114.1 | Last Updated 3 Mar 2008
Article Copyright 2008 by Pieter Alec Myburgh
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid