我需要用datagridview数据填充列表,
name fathername
x xa
y ya
datagridview看起来像上面的列名'name'和'fathername'
现在我需要填写清单
myList = New List(Of mydata)
Public Class mydata
Public name As String
Public fathername As String
End Class
任何人都可以帮忙。
答案 0 :(得分:0)
尝试这样的事情:
Dim myList As List(Of mydata) = New List(Of mydata)
Dim newItem As mydata
For Each row As DataGridViewRow In DataGridView1.Rows
newItem = New mydata()
newItem.name = row.Cells("name").Value
newItem.fathername = row.Cells("fathername").Value
myList.Add(newItem)
Next