C#winfrom|Winform UI界面设计例程——自定义toggleButton

winform c#界面设计 自定义控件 toggleButton C#winfrom|Winform UI界面设计例程——自定义toggleButton
文章图片

【C#winfrom|Winform UI界面设计例程——自定义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; private bool solidStyle = true;

//定义属性
//Properties [Category("自定义")] public Color OnBackColor { get{return onBackColor; } set { onBackColor 

    推荐阅读