我在表格上有一组单选按钮,形状像矩阵(6x10)。我想通过检查来绘制图案或显示任何数字(我想像点阵led一样使用它)。我通过软件创建单选按钮,所以我可以创建60个单选按钮,其中20个被检查,其中40个不是并绘制我的模式但是当我更改模式时,我无法绘制新模式,因为如果我检查一个,其他成为选中。我从不点击单选按钮一切都适用于代码。
我需要单独检查它们,所以有没有办法检查一个单选按钮,但避免其他人从中产生影响并让它们保持状态?
这是它看起来如何https://i.hizliresim.com/V9m0Vq.jpg https://i.hizliresim.com/lqmd7l.jpg
当我旋转它时,我希望所有人都朝地面移动(屏幕底部),但只有一个落下。
这是一个快速的“点”用户控件,您可以使用其Checked()属性打开/关闭:
public partial class Dot : UserControl
{
private bool _Checked = false;
public bool Checked
{
get
{
return _Checked;
}
set
{
_Checked = value;
this.Invalidate();
}
}
public Dot()
{
InitializeComponent();
this.DoubleBuffered = true;
this.SizeChanged += Dot_SizeChanged;
}
private void Dot_SizeChanged(object sender, EventArgs e)
{
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
int radius = (int)(Math.Min(this.ClientRectangle.Width, this.ClientRectangle.Height) / 2);
if (radius > 0)
{
double outerCircle = 0.95;
double innerCircle = 0.80;
Rectangle rc = new Rectangle(new Point(0, 0), new Size(1, 1));
rc.Inflate((int)(radius * outerCircle), (int)(radius * outerCircle));
Point center = new Point(this.ClientRectangle.Width / 2, this.ClientRectangle.Height / 2);
e.Graphics.TranslateTransform(center.X, center.Y);
e.Graphics.DrawEllipse(Pens.Black, rc);
if (this.Checked)
{
rc = new Rectangle(new Point(0, 0), new Size(1, 1));
rc.Inflate((int)(radius * innerCircle), (int)(radius * innerCircle));
e.Graphics.FillEllipse(Brushes.Black, rc);
}
}
}
}