Foros del Web » Programación para mayores de 30 ;) » Programación General »

crear y gestionar controles dinamicos en VB

Estas en el tema de crear y gestionar controles dinamicos en VB en el foro de Programación General en Foros del Web. Hola, tras unos dias leyendo sobre el tema y viendo que hay cosas parecidas para PHP y asp, me animo a plantear si es posible ...
  #1 (permalink)  
Antiguo 11/12/2007, 17:59
 
Fecha de Ingreso: febrero-2004
Mensajes: 1
Antigüedad: 21 años
Puntos: 0
crear y gestionar controles dinamicos en VB

Hola, tras unos dias leyendo sobre el tema y viendo que hay cosas parecidas para PHP y asp, me animo a plantear si es posible reducir este codigo:

la funcion la llamo hasta 20 veces para crear los 20 controles label y Radiobutton.


Public Sub CreaMyMultilineaTextBox(ByVal nummodalidad As Integer, ByVal Modalidades As ArrayTarifas)
Select Case nummodalidad
Case Is = 1
Dim RadioTar1 As New RadioButton()
Me.TabPageTarifa.Controls.Add(RadioTar1)
RadioTar1.Text = Nothing
RadioTar1.Enabled = True
RadioTar1.Location = New System.Drawing.Point(1, 5 + (50 * (nummodalidad - 1)))
Dim TarifaLabel1 As New Label()
Me.TabPageTarifa.Controls.Add(TarifaLabel1)
TarifaLabel1.Text = Modalidades.Mod_Nombre
If Modalidades.INFORMACION <> Nothing Then
TarifaLabel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))
Else
TarifaLabel1.BackColor = System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer))
End If
TarifaLabel1.Enabled = True
TarifaLabel1.Font = New System.Drawing.Font("Tahoma", 7.0!, System.Drawing.FontStyle.Bold)
TarifaLabel1.ForeColor = System.Drawing.SystemColors.HotTrack
TarifaLabel1.Location = New System.Drawing.Point(5, 5 + (50 * (nummodalidad - 1)))
'TarifaLabel1.Name = TarifaLabel(nummodalidad).Text
TarifaLabel1.Size = New System.Drawing.Size(207, 21)
'TarifaLabel1.TabIndex = nummodalidad
TarifaLabel1.Visible = True
Case Is = 2
Dim RadioTar2 As New RadioButton()
Me.TabPageTarifa.Controls.Add(RadioTar2)
RadioTar2.Text = Nothing
RadioTar2.Enabled = True
RadioTar2.Location = New System.Drawing.Point(1, 5 + (50 * (nummodalidad - 1)))
Dim TarifaLabel2 As New Label()
Me.TabPageTarifa.Controls.Add(TarifaLabel2)
TarifaLabel2.Text = Modalidades.Mod_Nombre
If Modalidades.INFORMACION <> Nothing Then
TarifaLabel2.BackColor = System.Drawing.Color.FromArgb(CType(CType(255, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer))
Else
TarifaLabel2.BackColor = System.Drawing.Color.FromArgb(CType(CType(128, Byte), Integer), CType(CType(255, Byte), Integer), CType(CType(128, Byte), Integer))
End If
TarifaLabel2.Enabled = True
TarifaLabel2.Font = New System.Drawing.Font("Tahoma", 7.0!, System.Drawing.FontStyle.Bold)
TarifaLabel2.ForeColor = System.Drawing.SystemColors.HotTrack
TarifaLabel2.Location = New System.Drawing.Point(5, 5 + (50 * (nummodalidad - 1)))
'TarifaLabel2.Name = TarifaLabel(nummodalidad).Text
TarifaLabel2.Size = New System.Drawing.Size(207, 21)
'TarifaLabel2.TabIndex = nummodalidad
TarifaLabel2.Visible = True
Case Is = 3


Me gustaria saber si es posible reducir el codigo a una funcion mas compacta y si posteriormente puedo de alguna manera manipular los radiobutton y los labels modificando su contenido/check, validando si se clican e incluso eliminarlos cuando sea necesario.

llevo una semana con la cuestion y no consigo encontrar ni en el guille algo que me funcione. Programo VB con VS2005 y .NET CompactFramework, es para una aplicacion mobile.

Gracias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta

SíEste tema le ha gustado a 1 personas (incluyéndote)




La zona horaria es GMT -6. Ahora son las 10:01.