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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Gopi KondalaraoPosted Jan 5, 2009, 6:00 AM
I want to change the shape of a button. how can I?
Gopi KondalaraoPosted Dec 27, 2008, 10:03 AM
Hi,
Thanks for giving the information for what I am searching.
Scott LyslePosted Dec 20, 2008, 12:09 AM
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;
}
}
}
}