locked
create radiobuttons at runtime RRS feed

  • Question

  • hello i am making an application in c# windows mobile . how do i create raidoButtons at runtime?
    Thursday, November 12, 2009 12:07 PM

Answers

  • Hi,


    I created the radio buttons when button is clicked. Check the code below. Hope this helps you.

    private void btn_Click(object sender, EventArgs e)
            {
                AddRadioButtons();
            }
    
    
            private void AddRadioButtons()
            {
                System.Windows.Forms.Panel panel1;
                System.Windows.Forms.RadioButton radioButton2;
                System.Windows.Forms.RadioButton radioButton1;
    
                panel1 = new System.Windows.Forms.Panel();
                radioButton1 = new System.Windows.Forms.RadioButton();
                radioButton2 = new System.Windows.Forms.RadioButton();
    
                // 
                // panel1
                // 
                panel1.Controls.Add(radioButton2);
                panel1.Controls.Add(radioButton1);
                panel1.Location = new System.Drawing.Point(0, 0);
                panel1.Name = "panel1";
                panel1.Size = new System.Drawing.Size(240, 100);
                // 
                // radioButton1
                // 
                radioButton1.Location = new System.Drawing.Point(41, 3);
                radioButton1.Name = "radioButton1";
                radioButton1.Size = new System.Drawing.Size(100, 20);
                radioButton1.TabIndex = 0;
                radioButton1.Text = "radioButton1";
                // 
                // radioButton2
                // 
                radioButton2.Location = new System.Drawing.Point(41, 29);
                radioButton2.Name = "radioButton2";
                radioButton2.Size = new System.Drawing.Size(100, 20);
                radioButton2.TabIndex = 4;
                radioButton2.Text = "radioButton2";
                Controls.Add(panel1); 
    
            }


    Regards,
    Malleswar
    • Proposed as answer by Christian Resma Helle Thursday, November 12, 2009 2:02 PM
    • Marked as answer by poojs Friday, November 13, 2009 5:22 AM
    Thursday, November 12, 2009 12:35 PM