【问题标题】:binding datagridview data to list将 datagridview 数据绑定到列表
【发布时间】:2013-11-15 08:13:46
【问题描述】:

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

谁能帮忙。

【问题讨论】:

    标签: vb.net datagridview


    【解决方案1】:

    试试这样的:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-04-20
      • 1970-01-01
      • 1970-01-01
      • 2011-03-12
      • 2016-11-19
      • 1970-01-01
      • 2011-05-07
      相关资源
      最近更新 更多