Click here to Skip to main content
Click here to Skip to main content

EmrColorComboBox

, 30 May 2006
Rate this:
Please Sign up or sign in to vote.
A skinned ComboBox contains Web colors
Sample Image - emrcolorcombobox.png

Introduction

Every Windows programmer and user knows color chooser controls and dialogs. Surely you see several types of them in several programs. One type of these controls could be a Color Combo Box. I need a color chooser combo box control in one of my projects, to easily select color. Because I couldn't find a suitable one; the best way was to create it myself.

Background

EmrColorComboBox is a NET inherited DLL user control created with C#. It contains Web colors. Users can't add or remove any of the colors. But there is an item titled other to choose colors not listed in the dropped down list. There is a property to set control appearance to standard or skinned.

Control

EmrColorComboBox is an inherited control and its source code; like every NET user control, contains properties, variables and events.

Properties; more than a standard combo box control are:

  • SelectedColor
  • ControlColor (The color of the control when the appearance is set to Skinned)
  • Appearance (Determines if the control displays skinned or standard.)

If you would like to ask more about the source, email me at ampiroid@hotmail.com.

How To Use

To use the control, in the VS.NET environment, right click on tool box and select Add/Remove Items. In Customize Toolbox dialog, select .NET Framework Component and browse EmrColorComboBox. As you select Ok, the control will be added to the toolbox. Simply drag and drop it to your form.

The file you have downloaded contains two folders, one is the compiled EmrColorComboBox with its source code and the other is a demo project.

The demo project is a Windows form with a panel, two checkboxes, a picture box and an EmrColorComboBox.

One of the checkboxes is used to set Combo Box disabled or not and another determines if the control appeared skinned or not.

private void checkBox2_CheckedChanged(object sender, System.EventArgs e)
{
    if(this.checkBox2.Checked)
        this.colorComboBox1.Appearance = 
            EmrColorComboBox.ColorComboBox.ControlView.Skinned;
    else
        this.colorComboBox1.Appearance = 
            EmrColorComboBox.ColorComboBox.ControlView.Standard;        
}

The PictureBox contains a color palette image. As you click picture box, the color of EmrColorComboBox will be changed to the selected color.

As you select a color in EmrColorComboBox panel back color will change to the selected color. If you select "other", standard color dialog box will appear and selecting more colors will be possible.

 private void colorComboBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
    this.panel1.BackColor = this.colorComboBox1.SelectedColor;
}

History

  • 30th May, 2006: Initial post

License

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

About the Author

Ampiroid

Iran (Islamic Republic Of) Iran (Islamic Republic Of)
No Biography provided

Comments and Discussions

 
Generaldoes not work in .Net 2.0 Pinmemberphilipsslg1-Dec-06 22:25 
GeneralRe: does not work in .Net 2.0 PinmemberAmpiroid18-Aug-08 7:44 

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

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

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 30 May 2006
Article Copyright 2006 by Ampiroid
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid