0

我需要用 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       

谁能帮忙。

4

1 回答 1

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
于 2013-11-15T00:13:46.207 回答