Winform UI界面设计例程——自定义toggleButton

winform c#界面设计 自定义控件 toggleButton

Winform UI界面设计例程——自定义toggleButton_第1张图片

新建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 

你可能感兴趣的:(C#winfrom,UI,设计,ui,c#,开发语言,checkBox,winform)