Colección de controles

31/07/2006 - 17:07 por Guillermo | Informe spam
Amigos, tengo un problemas, he creado una clase para manejar un arreglo de
lable, el problema es que cuando ejecuto el programa no se muestra el label
que agrego a mi form.

Clase:

Public Class clsLblArrays
Inherits System.Collections.CollectionBase
Private ReadOnly HostForm As System.Windows.Forms.Form
Default Public ReadOnly Property Item(ByVal Index As Integer) As
System.Windows.Forms.Label
Get
Return CType(Me.List.Item(Index), System.Windows.Forms.Label)
End Get
End Property
Public Function AddNewLabel() As System.Windows.Forms.Label

Dim aLabel As New System.Windows.Forms.Label

Me.List.Add(aLabel)

aLabel.Location = New Point(24, 140)
aLabel.Text = "Hola Mundo"
aLabel.AutoSize = True

HostForm.Controls.Add(aLabel)

Return aLabel

End Function
Public Sub New(ByVal host As System.Windows.Forms.Form)
HostForm = host
Me.AddNewLabel()
End Sub
End Class

Instacia de la Clase:


Dim lblChapter As clsLblArrays

lblChapter = New clsLblArrays(Me)

lblChapter.AddNewLabel()

Me gustaria en lo que puedan ayudarme o darme algun truco sobre esto.

Preguntas similare

Leer las respuestas

#1 Jose Luis
31/07/2006 - 19:07 | Informe spam
Pues lo he probado y funciona. No sera que se crean todos en el mismo sitio
y no te des cuenta????
aLabel.Location = New Point(24, 140)



Suerte.
"Guillermo" escribió en el mensaje
news:
Amigos, tengo un problemas, he creado una clase para manejar un arreglo de
lable, el problema es que cuando ejecuto el programa no se muestra el
label
que agrego a mi form.

Clase:

Public Class clsLblArrays
Inherits System.Collections.CollectionBase
Private ReadOnly HostForm As System.Windows.Forms.Form
Default Public ReadOnly Property Item(ByVal Index As Integer) As
System.Windows.Forms.Label
Get
Return CType(Me.List.Item(Index), System.Windows.Forms.Label)
End Get
End Property
Public Function AddNewLabel() As System.Windows.Forms.Label

Dim aLabel As New System.Windows.Forms.Label

Me.List.Add(aLabel)

aLabel.Location = New Point(24, 140)
aLabel.Text = "Hola Mundo"
aLabel.AutoSize = True

HostForm.Controls.Add(aLabel)

Return aLabel

End Function
Public Sub New(ByVal host As System.Windows.Forms.Form)
HostForm = host
Me.AddNewLabel()
End Sub
End Class

Instacia de la Clase:


Dim lblChapter As clsLblArrays

lblChapter = New clsLblArrays(Me)

lblChapter.AddNewLabel()

Me gustaria en lo que puedan ayudarme o darme algun truco sobre esto.
email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida