Do everything if needed

Only to note everything I meet.

C#实现可自定义图片的checkBox

不多说,直接上源码。将这些代码放到一个文件里,加入工程,就可以像其它控件一样使用了。

    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();
        }
    }

posted on 2020-04-22 13:18  microsun  阅读(730)  评论(0编辑  收藏  举报

导航