不多说,直接上源码。将这些代码放到一个文件里,加入工程,就可以像其它控件一样使用了。
public partial class CheckButton : Button
{
Image checkImage;
[Description("Image when checked"),Category("Special property")]
public Image CheckedImage
{
get { return checkImage; }
set { checkImage = value; }
}
Image unCheckImage;
[Description("Image when unchecked"), Category("Special property")]
public Image UncheckedImage
{
get { return unCheckImage; }
set { unCheckImage = value; }
}
bool checkedState;
[Description("Checked state"), Category("Special property")]
public bool CheckState
{
get { return checkedState; }
set { checkedState = value; }
}
public CheckButton()
{
InitializeComponent();
}
}