Click here to Skip to main content
15,921,941 members
Articles / Programming Languages / XML

Rainbow Button

Rate me:
Please Sign up or sign in to vote.
1.83/5 (14 votes)
22 Dec 20031 min read 79K   1.1K   35   2
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.

C#
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.


Written By
United Kingdom United Kingdom
David lives in London, UK.

Programming history includes, C/C++, C#, PHP, JavaScript and other web related languages.

Comments and Discussions

 
GeneralSweet Pin
Shin-Ra3-Apr-07 12:12
Shin-Ra3-Apr-07 12:12 
The only problem I found was that on the form in Visual Studios 2005 was that it would be perfect in the IDE but when going to run it, it comes out orange and not the correct colours.
GeneralCould u Xplain Me Pin
ajith_98215-Oct-05 2:43
ajith_98215-Oct-05 2:43 

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.