Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/05/2008, 16:08
dr4k0
 
Fecha de Ingreso: mayo-2008
Mensajes: 1
Antigüedad: 16 años, 9 meses
Puntos: 0
Respuesta: C# - Agregar un control en ejecucion

Bueno pues a mi me funciono bastante algo de lo ke aki comentaron y yo les envio mi solucion

Código:
 private void AgregaEtiqueta(string str)
        {
            try
            {
                String nomctrl = "lbl_" + il.ToString();
                Label lbl = new Label();
                lbl.Text = str;
                lbl.Location = new Point(10, pos + 20);
                lbl.Visible = true;
                lbl.Name = nomctrl;
                lbl.AutoSize = true;
                lbl.Refresh();
                grpPreview.Controls.Add(lbl);
                grpPreview.Refresh();
                grpPreview.Visible = true;
                lbl = null;
                pos = pos + 20;
                il = il + 1;
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
            }
        }
.

Espero ke sto sea de utilidad para alguien mas en este caso yo agrego etiketas y no botones.

Las variables 'il' y 'pos' son contadores uno para la posicion del control y la otra unicamente para generar el nombre (lbl_1, lbl_2, lbl_3... lbl_n).