-1

I have a group of radio buttons on the form, which are shaped like a matrix(6x10). I want to draw a pattern or display any number by checking them (i want to use it like dot matrix led). I create radio buttons by software so i can create 60 radio buttons that 20 of them are checked,40 of them are not and draw my pattern but when i change the pattern, i cant draw the new one because if i check one, others become unchecked. I never click on radio buttons everything works on code.

I need to check them separately so is there any way to check one radio button but avoid others to effect from that and let them remain their status?

this is how it looks https://i.hizliresim.com/V9m0Vq.jpg https://i.hizliresim.com/lqmd7l.jpg

when i rotate it, i want all to move towards the ground(bottom of the screen) but only one of them falls.

  • 1
    Inverse dupe of https://stackoverflow.com/questions/2178240/how-do-i-group-windows-form-radio-buttons, but basically the advice is to put your controls in different parent containers. – gunr2171 Apr 19 '19 at 18:35
  • Why not make your own **UserControl** that you can toggle the state of, and make it draw a unfilled/filled circle based on that state? – Idle_Mind Apr 19 '19 at 19:04

1 Answers1

0

Here's a quick "Dot" UserControl you can toggle on/off with its Checked() propperty:

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);
            }
        }            
    }

}
Idle_Mind
  • 38,363
  • 3
  • 29
  • 40