I have a user control in which I implement the following interface:
Public Interface IPropiedades
Property NombreUsuario() As String
Property LabelInstancia() As String
Property NombreInstancia() As String
Property EstacionTrabajo() As String
Property Periodo() As String
Property Status() As String
End Interface
In the UC I implement it from the sig. way:
Public Class UC_StatusControlBar
Implements IPropiedades
Public Property NombreUsuario As String Implements IPropiedades.NombreUsuario
Public Property LabelInstancia As String Implements IPropiedades.LabelInstancia
Public Property NombreInstancia As String Implements IPropiedades.NombreInstancia
Public Property EstacionTrabajo As String Implements IPropiedades.EstacionTrabajo
Public Property Periodo As String Implements IPropiedades.Periodo
Public Property Status As String Implements IPropiedades.Status
Public Sub New()
InitializeComponent()
End Sub
Private Sub UC_StatusControlBar_Load(sender As Object, e As EventArgs) Handles MyBase.Load
lbl_nombreinstancia.Text = NombreInstancia
End Sub
End Class
Now it is assumed that where I set the label to the value of the property of that user control, I would have to show it just when it is loaded (by the Load event)
But when I use it in a Winform
I can access its properties both at the design and code level
UC_StatusControlBar.NombreInstancia = "Algo"
The problem is that when I run the form it appears blank, that is, it does not show it to me, except if by design in the control properties box if I put a default value there it does show it.
I want to know if someone could tell me what I'm missing or what I'm doing wrong. Thank you very much.
I have found the solution:
I can't assign (for some reason I don't understand or know yet) property values anywhere else in my winform other than in the constructor.
According to VisualStudio this doesn't work:
But if in the constructor:
I hope it helps someone. Greetings and thanks.