Hi Alexandre,
for demo try following code:
Imports System.Threading
Public Class Form25
Private sc As SynchronizationContext = SynchronizationContext.Current
Private myControl As New Form25CC1
Private Sub Form25_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.Controls.Add(myControl)
Task.Factory.StartNew(New Action(Async Sub()
Await Task.Delay(2000)
myControl.Persons("Alex").Age = "50"
sc.Post(New SendOrPostCallback(Sub()
Me.Refresh()
End Sub), Nothing)
End Sub))
End Sub
End Class
End Class
Public Class Form25CC1
Inherits Control
Public Sub New()
Me.Width = 200
Me.Height = 200
PersonsList.Add(New Person With {.Name = "Peter"})
PersonsList.Add(New Person With {.Name = "Alex"})
End Sub
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
For i = 0 To PersonsList.Count - 1
e.Graphics.DrawString($"Name: {PersonsList(i).Name}, Age: {PersonsList(i).Age}", Me.Font, Brushes.Black, New PointF(10, i * 20))
Next
MyBase.OnPaint(e)
End Sub
Public ReadOnly Property Persons(name As String) As Person
Get
Return PersonsList.Find(Function(p)
Return p.Name = name
End Function)
End Get
End Property
Private PersonsList As New List(Of Person)
Public Class Person
Public Property Name As String
Public Property Age As String = "0"
End Class
End Class
or property like this:
Public ReadOnly Property Persons(name As String) As Person
Get
Return PersonsList.Find(Function(p) p.Name.Equals(name))
End Get
End Property
Result: