Tag: toggleswitch

在Windows窗体中切换开关控件

我正在使用CheckBox设计一个Toggle Switch CheckBox ,但是目前我的控件只画了一个圆圈。 如何绘制如下图像的圆形图形以及如何根据控件的值更改圆的位置以表示已检查和未检查的状态,如下图所示: 这是我的代码: public class MyCheckBox:CheckBox { public MyCheckBox() { this.Appearance = System.Windows.Forms.Appearance.Button; this.BackColor = Color.Transparent; this.TextAlign = ContentAlignment.MiddleCenter; this.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.FlatAppearance.BorderColor = Color.RoyalBlue; this.FlatAppearance.BorderSize = 2; } protected override void OnPaint(PaintEventArgs e) { this.OnPaintBackground(e); using (var path = new GraphicsPath()) { var c = e.Graphics.ClipBounds; var r = this.ClientRectangle; r.Inflate(-FlatAppearance.BorderSize, […]