dynamic radiobutton array create in groupbox array

23 Views Asked by At

I have a question. I am running the following code in c# windows form application on visual studio. I want to have a radiobutton in each groupbox array. but only in the first sequence the radiobutton occurs. No radiobutton occurs in other groupbox strings. why ?

    private void Form1_Load(object sender, EventArgs e)
        {


            GroupBox[] groupBox = new GroupBox[100];
            Label[] labels = new Label[100];
            System.Windows.Forms.RadioButton[] radioButtonA = new System.Windows.Forms.RadioButton[100];
            System.Windows.Forms.RadioButton[] radioButtonB = new System.Windows.Forms.RadioButton[100];
            System.Windows.Forms.RadioButton[] radioButtonC = new System.Windows.Forms.RadioButton[100];

            for (int i = 0; i < 7; i++)
            {

                groupBox[i] = new GroupBox();
                groupBox[i].Name = "groupBox" + i.ToString();
                // groupBox[i].Location=new Point(0,300);
                groupBox[i].Size = new Size(550, 60);
                groupBox[i].Top = i * 110;
                groupBox[i].Left = 10;
                this.Controls.Add(groupBox[i]);

                /* Dinamik Label Tanımlama kısmı  */
                labels[i] = new Label();
                labels[i].Name = "Label" + i.ToString();
                labels[i].Text =     "kelimesinin türkçe karşılığı nedir ?";
                // labels[i].Location = new Point(20, 5 * (i * 20));
                labels[i].Width = 500;
                this.Controls.Add(labels[i]);
                groupBox[i].Controls.Add(labels[i]);




                /* Dinamik RadiobuttonA şıkkı tanımlama kısmı */
                radioButtonA[i] = new System.Windows.Forms.RadioButton();
                radioButtonA[i].Name = "RadioA" + i.ToString();
                 radioButtonA[i].Text = "A Şıkkı";
                radioButtonA[i].Location = new Point(20, ((i * 100)) + 30);
                this.Controls.Add(radioButtonA[i]);
                groupBox[i].Controls.Add(radioButtonA[i]);



                /* Dinamik RadiobuttonB şıkkı tanımlama kısmı */
                radioButtonB[i] = new System.Windows.Forms.RadioButton();
                radioButtonB[i].Name = "RadioB" + i.ToString();
                 radioButtonB[i].Text = "B Şıkkı";
                radioButtonB[i].Location = new Point(150, ((i * 100)) + 30);
                this.Controls.Add(radioButtonB[i]);
                groupBox[i].Controls.Add(radioButtonB[i]);

                /* Dinamik RadiobuttonC şıkkı tanımlama kısmı */
                radioButtonC[i] = new System.Windows.Forms.RadioButton();
                radioButtonC[i].Name = "RadioC" + i.ToString();
                 radioButtonC[i].Text = "C Şıkkı";
                radioButtonC[i].Location = new Point(280, ((i * 100)) + 30);
                this.Controls.Add(radioButtonC[i]);
                groupBox[i].Controls.Add(radioButtonC[i]);

            }
}

to use in my project

0

There are 0 best solutions below