C#自定义Button按钮控件
在实际项目开发中经常可以遇到.net自带控件并不一定可以满足需要,因此需要自定义开发一些新的控件,自定义控件的办法也有多种,可以自己绘制线条颜色图形等进行重绘,也可以采用已有的控件作为控件的一个组成部分从而组成新的控件,本例中使用后者这里做了一个简单的按钮控件,特意帖上来,如有不足之处请见谅!
按钮素材:
这里的小图标是从V2013标题栏截取的
截图图标如下,有需要的可以自行:images下载
Button按钮控件设计
1.添加一个用户自定义控件ButtonEX
按钮组成:lable标签一个,Dock设置为填充
2.添加控件属性
1 /// <summary> 2 /// 控件的默认图片 3 /// </summary> 4 private Image _imageDefault = null; 5 6 [Description("控件的默认图片")] 7 public Image ImageDefault 8 { 9 get { return _imageDefault; } 10 set 11 { 12 _imageDefault = value; 13 label.Image = _imageDefault; 14 } 15 } 16 /// <summary> 17 /// 光标移动到控件上方显示的图片 18 /// </summary> 19 private Image _imageMove = null; 20 [Description("光标移动到控件上方显示的图片")] 21 public Image ImageMove 22 { 23 get { return _imageMove; } 24 set { _imageMove = value; } 25 } 26 /// <summary> 27 /// 光标离开控件显示的图片 28 ///