65.9K
CodeProject is changing. Read more.
Home

Rainbow Button

starIcon
emptyStarIcon
starIcon
emptyStarIconemptyStarIconemptyStarIcon

1.83/5 (12 votes)

Dec 23, 2003

1 min read

viewsIcon

79152

downloadIcon

1152

Making a rainbow colored button using a custom control

Introduction

This is my first article and I am sorry for any mistakes. ;-)

The control is a rainbow coloured button. It has all the features of a normal button, it is also fully customizable with your own colours. I would like to quickly thank Alexandr Khilov for his superb article on the cuteButton.

Background

I was on the bus coming back from work when I saw a rainbow scarf and thought I'd make a rainbow button. Well enough of that, let's get down to the code.

How to Use the Code

The rainbow button can be accessed from the System.Windows.Forms namespace. It has two constructors, one takes five colours and the other takes none. The later assigns default colours to the button. You are able to change the colours with an immediate effect on the button.

private System.Windows.Forms.rainbowButton rainbowButton1;
rainbowButton1 = new System.Windows.Forms.rainbowButton (); 
    // with default colours
rainbowButton1 = new System.Widows.Forms.rainbowButton
    (Colors.Blue, Colors.Red, Colors.Pink, Colors.Aqua, Colors.Green);
     // with 5 user defined colours        

When a colour is changed, the ColorChanged event is raised to use at your disposal. The rainbow button has the workings of any other button, so all normal events are available.

Finishing Up

For a complete look at the control, have a peek at the code and mess about with it. If there is any problem with the control, please email me. Enjoy the control!

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.