We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 35,360 times

Contents

Downloads

Related Categories

The ColorPicker WinForms Control - Introduction

palom

Introduction

Although the .NET framework provides quite a rich collection of UI controls and components for WinForms development, there is one particular control that's been missing. I'm talking about a color-picker control with drop-down color selection capabilities, just like the one used within the Visual Studio .NET property browser for editing Color-typed properties. Based on these observations, I've decided to implement a ColorPicker control with the following features:
  • 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.

I live in Slovakia with my wife, two sons (fulltime), one daughter (occasionally) and a dog. I've been doing Microsoft Windows development since 1988; primarily in VB. I'm a big fan of the MS .NET framework, publisher of the www.VBInfoZine.com ezine and the author of the Dynamic AutoComplete Tool .NET component (dact.lamarvin.com).

Comments

  • Re: [4327] The ColorPicker WinForms Control

    Posted by adeel_meer on 12 Sep 2007

    Excellent control.


    I have used it in win forms and it works quite nicly.


    only one small issue. when you press the button and 3 tabbed popup drops down. if you click anywhere where ...