winform c#界面设计 自定义控件 toggleButton
新建winform项目,添加新类,并重新命名为myToggleButton,打开新类,并引用如下
using System.Windows.Forms; using System.Drawing; using System.Drawing.Drawing2D; using System.ComponentModel;
myToggleButton类继承CheckBox
public class myToggleButton : CheckBox {}
定义字段
//Fields private Color onBackColor = Color.MediumSlateBlue; private Color onToggleColor = Color.WhiteSmoke; private Color offBackColor = Color.Gray; private Color offToggleColor = Color.Gainsboro; privat