Hi all,
I want to know How to Create Custom Button (with my own events) and add to Toolkit in c#.net.
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Scott LysleRank #49 · 31K reputationPosted Dec 19, 2008, 7:09 PM EST
Well, you can define a class that inherits from the existing button class and override existing properties and you can define your own events for it; this one overrides the fore and background colors of the base button class to force the button to always have a maroon forecolor and a slateblue background color.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing;
namespace CustomButtonDemo
{
public class CButton : System.Windows.Forms.Button
{
private Color mForeColor;
private Color mBackColor;
public CButton()
{
mForeColor = Color.Maroon;
mBackColor = Color.SlateBlue;
}
public override System.Drawing.Color BackColor
{
get
{
return mBackColor;
}
set
{
//mBackColor = value;
}
}
public override System.Drawing.Color ForeColor
{
get
{
return mForeColor;
}
set
{
//mForeColor = value;
}
}
}
}
Gopi Kondalarao12 reputationPosted Dec 27, 2008, 5:03 AM EST
Hi,
Thanks for giving the information for what I am searching.
Gopi Kondalarao12 reputationPosted Jan 5, 2009, 1:00 AM EST
I want to change the shape of a button. how can I?