Hosting domitienda.com
MisTrucos.Net - El rincón de los trucos informáticos El rincón de los trucos informáticos
Trucos C# > Crear checkbox dinamicos

Con esta función podrás crear checkbox de forma dinámica.


 


#region dyanamic checkboxes


//Function to generate the dyanamic checkboxes


private void AddCheckboxes(string strCheckboxText)


          {


                try


                {


                     if(PnlTimeExpence.HasControls())


                     {


                           return;


                     }


                     for(int intControlIndex=0;intControlIndex=5;intControlIndex++)


                     {


                           chkList1 =new CheckBox();


                           chkList1.Text = strCheckboxText;


                           chkList1.ID="Chk"+intControlIndex;


                           chkList1.Font.Name = "Verdana";


                           chkList1.Font.Size = 9;


                           PnlControl.Controls.Add(chkList1);


                           PnlControl.Controls.Add(new LiteralControl("<;br>;"));


                     }


                }


                catch(Exception exp)


                {


                     throw new Exception(exp.Message);


                }


          }


#endregion