- The control should look and act like a button.
- The button should be colored with the currently selected color and, optionally, it should display the currently selected color's name.
- Clicking the button should drop-down the built-in WinForms color selector and the control should change its appearance to a "pushed down" look.
The main design goals were implementation simplicity and the ability to reuse the control in either binary, or in source code form (VB.NET source code; just include the ColorPicker.vb file into your project and you're done).
The demo application
The following is the important part of the ColorPicker's public contract (the semantics should be self-explanatory):
Namespace LaMarvin.Windows.Forms
Public Class ColorPicker Inherits Control
Public Event ColorChanged As EventHandler
Public Property Color() As Color
For those of you in a hurry, you can download the control along with an accompanying demo application here.
But wait!
If you want to learn something about the inner workings of the WinForms design-time support, as well as some undocumented .NET framework tricks, please, read on.
Comments