Public mr As New markerRow
Dim aList As New List(Of markerRow)
For Each dtrow In markerDtable.Rows
mr.MarkerName = dtrow("MarkerName")
mr.CameraID = dtrow("CameraID")
mr.HostAddress = dtrow("HostAddress")
aList.Add(New markerRow())
Next
Here, you are creating one markerRow
named mr
, and update it for every row in the DataTable
. Also, for every row, you create another markerRow
, and add that new one to aList
.
For Each elem In aList
listbox.Items.Add(mr.MarkerName)
listbox.Items.Add(mr.CameraID)
Next
Then, for each element in aList
, you add two items to the ListBox
, and everytime it's MarkerName
and CameraID
from mr
, and not the data from the elements of aList
.
You're probably looking for something like:
Dim aList As New List(Of markerRow)
For Each dtrow In markerDtable.Rows
Dim mr = New markerRow() ' create a new markerRow for every row '
mr.MarkerName = dtrow("MarkerName")
mr.CameraID = dtrow("CameraID")
mr.HostAddress = dtrow("HostAddress")
aList.Add(mr) ' add the new markerRow to the list '
Next
For Each elem In aList
listbox.Items.Add(elem.MarkerName)
Next