dimanche 13 décembre 2015

How Do I call individual radio buttons on if else statement when buttons are created dynamically?

I have the code above in button1 from someone in this forum, I cannot figure out what the next step is. Let say I have 4 radio buttons can someone show me an example of how to use the if else statement to each individual radio buttons based on their individual if else statement when I click button2.

      var list = new List<string>
        {
            "First radio text", "Second radio text", "Third radio text", "And so on"
        };

        this.panel1.SuspendLayout();
        for (var i = 0; i < list.Count; i++)
        {
            var r = new RadioButton();
            r.Text = list[i];
            r.Tag = i;
            r.Name = string.Format("r{0}", i);
            r.Dock = DockStyle.Top;
            r.CheckedChanged += r_CheckedChanged;
            this.panel1.Controls.Add(r);
            r.BringToFront();
        }
        this.panel1.ResumeLayout(true);

Aucun commentaire:

Enregistrer un commentaire