My preference is what techgnome mentioned in regards to a List(Of T).
Here I load data using the following class.
Screenshot Attachment 182847
Read the data from where ever e.g. database, text file, json file etc.Code:Public Class Employee Public Property EmployeeID As Integer Public Property TitleOfCourtesy As String Public Property FirstName As String Public Property LastName As String Public Property Fullname As String Public Property BirthDate As Date Public Property HomePhone As String Public Overrides Function ToString() As String Return Fullname End Function End Class
Code:Public Class Form1 Private ReadOnly EmployeeBindingSource As BindingSource = New BindingSource() Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load EmployeeBindingSource.DataSource = Operations.ReadEmployee() EmployeeComboBox.DataSource = EmployeeBindingSource End Sub Private Sub CurrentButton_Click(sender As Object, ea As EventArgs) Handles CurrentButton.Click Dim e = CType(EmployeeBindingSource.Current, Employee) MessageBox.Show($"{e.TitleOfCourtesy} {e.LastName}{vbCr}{e.BirthDate.ToShortDateString()}{vbCr}{e.HomePhone}") End Sub End Class




Reply With Quote
