Click here to Skip to main content
15,884,537 members
Articles / Programming Languages / C#
Article

Button derived color selection control in C#

Rate me:
Please Sign up or sign in to vote.
4.21/5 (15 votes)
22 Dec 20031 min read 82.4K   1.2K   31   8
Button derived color selection control similar to the one used in MS Office applications.

Sample Image - ColorButton.gif

Introduction

ColorButton is a color selection control derived from System.Windows.Forms.Button similar to the one used in MS Office applications. It uses the same colors like MS Office, including support for "Automatic" and "More Colors".

How To Use

Add a normal Button to your Windows Form and set the Text property to an empty string. Then manually change all occurrences of System.Windows.Forms.Button to ColorButton.ColorButton for this button in the source file.

Properties

ColorButton adds the following new properties:

Color (get/set)

Gets or sets the selected color. System.Drawing.Color.Transparent is used for the "Automatic" color.

Automatic (get/set)

Gets or sets the string for the "Automatic" button. Setting this to an empty string disables the "Automatic" color feature.

MoreColors (get/set)

Gets or sets the string for the "More Colors" button. Setting this to an empty string disables the "More Colors" color feature.

Events

ColorButton adds the following new event:

Changed

This event occurs whenever the user changes the selected color. Use the Color property to determine what the selected color is.

History

  • 1.1
    • Added keyboard support to color panel (thanks to Ignazio Di Napoli)
    • Button handles disabled state correctly
    • Button is drawn pushed, if color panel is visible
  • 1.0
    • Initial release

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Austria Austria
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
QuestionHow to use this in VB Pin
J3ssy Pmntra29-Sep-14 6:13
J3ssy Pmntra29-Sep-14 6:13 
GeneralFixed Control for Clipregion Pin
CodeMonkey3315-Sep-06 6:23
CodeMonkey3315-Sep-06 6:23 
GeneralReworked as a .NET 2.0 ToolStripButton Pin
Los Guapos7-Mar-06 3:37
Los Guapos7-Mar-06 3:37 
GeneralRe: Reworked as a .NET 2.0 ToolStripButton Pin
shlomifr7-Aug-09 3:05
shlomifr7-Aug-09 3:05 
GeneralVisual Effects Pin
Anthony D.29-Aug-04 8:46
Anthony D.29-Aug-04 8:46 
GeneralNice Job Pin
Tom Spink22-Dec-03 7:08
Tom Spink22-Dec-03 7:08 
GeneralRe: Nice Job Pin
Thomas Ascher22-Dec-03 23:22
Thomas Ascher22-Dec-03 23:22 
Thanks! Smile | :)
GeneralRe: Nice Job Pin
Tom Spink23-Dec-03 0:06
Tom Spink23-Dec-03 0:06 

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.