Click here to Skip to main content
11,920,394 members (37,392 online)
Click here to Skip to main content
Add your own
alternative version


17 bookmarked

A clickable button

, 13 Jun 2002
Rate this:
Please Sign up or sign in to vote.
An immensely handy clickable button.
<!-- Download Links -->

Welcome to ClickableButton!

As useful and as popular as Chris Maunder's "An unclickable button" article and class is, I thought that a clickable button might also be useful. While my ClickableButton class is implemented specifically for .NET, the very same techniques can be used in nearly every object-oriented windowing library.


Here's a sample of using the ClickableButton class. Notice that we've handled the Click event to show a message box of appreciation:


To use ClickableButton, simple add it to your form, either via the WinForms designer or manually, setting properties as appropriate:

class Form1 : Form {
  ClickableButton button1;
  void InitializeComponent() {
    this.button1 = new ClickableButton();
    this.button1.Location = new System.Drawing.Point(24, 24);
    this.button1.Name = "button1";
    this.button1.Size = new System.Drawing.Size(200, 120);
    this.button1.TabIndex = 0;
    this.button1.Text = "Click Me!";
    this.button1.Click += new System.EventHandler(this.button1_Click);
    this.Controls.AddRange(new System.Windows.Forms.Control[] { this.button1});


Notice from the sample application that the ClickableButton will show itself as a shadowed square with a text label. When the user uses the mouse to click on the ClickableButton, it will take on a depressed look 'n' feel and fire the Click event, which a hosting program can handle. For example, the sample handles the Click event like so:

void button1_Click(object sender, EventArgs e) {
  MessageBox.Show("Ohhh... That's nice.", "ClickableButton Clicked");


My ClickableButton class derives from the base class System.Windows.Forms.Button class and adds absolutely nothing:

public class ClickableButton : System.Windows.Forms.Button


While this button is fairly functional, it's not nearly as fun as ChrisM's unclickable button. Potential ways to make it more fun include:

  • Calling the user nasty names.
  • Formatting "c:".
  • Switching the user interface language to Spanish.
  • Spawning a virus.
  • Overheating the CPU.
  • Resetting the user's MineSweeper high scores.


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


About the Author

Chris Sells
Web Developer
United States United States
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralMy vote of 1 Pin
io.akimov29-Jul-10 7:49
memberio.akimov29-Jul-10 7:49 
GeneralWPF Pin
Adrian Schröder14-Sep-09 1:24
memberAdrian Schröder14-Sep-09 1:24 
GeneralMy Search Is Complete! Pin
Felix De Herrera15-Jul-09 14:50
memberFelix De Herrera15-Jul-09 14:50 
GeneralPlease ... Pin
mbaocha6-May-09 13:42
membermbaocha6-May-09 13:42 
GeneralPlease anybody help me for how to sending Http request and how to get response of http for c#.Net Pin
dudhat8-Feb-08 6:48
memberdudhat8-Feb-08 6:48 
GeneralLOL Pin
sk8er_boy2877-May-07 22:41
membersk8er_boy2877-May-07 22:41 
GeneralNow your in trouble Pin
Giles21-Oct-02 13:46
memberGiles21-Oct-02 13:46 
Generalhahahahahahahahahha Pin
Swinefeaster7-Jul-02 0:03
memberSwinefeaster7-Jul-02 0:03 
GeneralSome industry perspective Pin
Mike Sax25-Jun-02 8:23
memberMike Sax25-Jun-02 8:23 
The clickable button was invented by Xerox 25 years ago. Mac users have had access to for it nearly two decades. I have a lot of appreciation and respect for Chris in general, but he should not get (or claim) credit for this invention.

Mike Sax
Rock Solid Components™

GeneralRe: Some industry perspective Pin
David Cunningham25-Jun-02 18:45
adminDavid Cunningham25-Jun-02 18:45 
GeneralRe: Some industry perspective Pin
Nishant S25-Jun-02 19:09
memberNishant S25-Jun-02 19:09 
GeneralRe: Some industry perspective Pin
Brian Delahunty5-Oct-02 3:26
editorBrian Delahunty5-Oct-02 3:26 
GeneralException raised when started Pin
Patko17-Jun-02 23:39
memberPatko17-Jun-02 23:39 
GeneralRe: Exception raised when started Pin
Rob van der Veer8-Jun-04 3:25
memberRob van der Veer8-Jun-04 3:25 
GeneralImprovement Suggestion Pin
Ed Gadziemski15-Jun-02 4:25
memberEd Gadziemski15-Jun-02 4:25 
QuestionCan you please post code for this is VB. I have need for in project Pin
zjouing14-Jun-02 23:22
memberzjouing14-Jun-02 23:22 
GeneralCool! Pin
Mazdak14-Jun-02 20:05
memberMazdak14-Jun-02 20:05 
GeneralNice. But can Pin
Chris Losinger14-Jun-02 10:29
memberChris Losinger14-Jun-02 10:29 
GeneralWOW!!!! Pin
CWizard14-Jun-02 10:14
memberCWizard14-Jun-02 10:14 
GeneralRe: WOW!!!! Pin
NebuGranny29-Mar-04 10:55
memberNebuGranny29-Mar-04 10:55 
QuestionI can't get it to work? Pin
Roger Allen14-Jun-02 7:37
memberRoger Allen14-Jun-02 7:37 
GeneralFun Pin
Dieder14-Jun-02 5:31
memberDieder14-Jun-02 5:31 
GeneralRe: Fun Pin
Marc Richarme14-Jun-02 10:10
memberMarc Richarme14-Jun-02 10:10 
GeneralAnother fun idea (article suggestion) Pin
Black Cat14-Jun-02 5:02
memberBlack Cat14-Jun-02 5:02 
GeneralYou're soooooooo evil Pin
James T. Johnson13-Jun-02 22:48
subeditorJames T. Johnson13-Jun-02 22:48 
GeneralRe: You're soooooooo evil Pin
yannc14-Jun-02 0:39
memberyannc14-Jun-02 0:39 
GeneralNo future. Pin
fnicola13-Jun-02 22:31
memberfnicola13-Jun-02 22:31 
GeneralRe: No future. Pin
leppie14-Jun-02 5:23
memberleppie14-Jun-02 5:23 
GeneralRe: No future. Pin
Chris Losinger14-Jun-02 11:23
memberChris Losinger14-Jun-02 11:23 
GeneralRe: No future. Pin
robinds19-Jun-02 4:49
memberrobinds19-Jun-02 4:49 
GeneralRe: No future. Pin
Chris Losinger19-Jun-02 4:54
memberChris Losinger19-Jun-02 4:54 
GeneralRe: No future. Pin
Sander198117-Oct-03 3:19
memberSander198117-Oct-03 3:19 
GeneralSimple & Consise Pin
Norm Almond13-Jun-02 22:33
memberNorm Almond13-Jun-02 22:33 
GeneralRe: Simple & Consise Pin
peterchen14-Jun-02 1:04
memberpeterchen14-Jun-02 1:04 
GeneralSuperb! Pin
Vernero Cifagni13-Jun-02 22:12
memberVernero Cifagni13-Jun-02 22:12 
Nish - Native CPian13-Jun-02 22:11
memberNish - Native CPian13-Jun-02 22:11 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151120.1 | Last Updated 14 Jun 2002
Article Copyright 2002 by Chris Sells
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid