Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vb.net/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在vb.net中将(类的)列表绑定到datagridview_Vb.net_Data Binding_Datagridview - Fatal编程技术网

在vb.net中将(类的)列表绑定到datagridview

在vb.net中将(类的)列表绑定到datagridview,vb.net,data-binding,datagridview,Vb.net,Data Binding,Datagridview,我有一个类,它包含从数据流填充的数据列表。我想将该列表绑定到datagridview,以便它像列表一样自动填充。但是,当数据进入时,列表不会刷新。我有这样的东西 Public class MyClass Private mData as list(Of networkData) Public Property Data() as list(Of networkData) Get return mData End Get

我有一个类,它包含从数据流填充的数据列表。我想将该列表绑定到datagridview,以便它像列表一样自动填充。但是,当数据进入时,列表不会刷新。我有这样的东西

Public class MyClass
    Private mData as list(Of networkData)
    Public Property Data() as list(Of networkData)
        Get
            return mData
        End Get
        Set
            mData = value
        End Set
     End Property
        ' some other properties that aren't imporant
        ' stuff to load Data with data from network stream
end class
Public class networkDat
    Private rawdata as string
    Public Property rawdata() as string
        Get
            return mrawdata
        End Get
        Set
            mrawData = value
        End Set
     End Property
        ' some other properties that aren't imporant
        ' functions to parse rawdata into the other properties
End Class

'form
Public Class dataviewer
    Dim dataView as datagridViewer = new datagridviewer()
    Private Sub dataviewer_load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         dim x as myClass = new myClass() 'new will start the datastream
         datagridview.datasource = x.Data
    End Sub

因为我启动了datastream,所以第一个dataviewer将有一组初始数据。但是,它不会随着新数据的到来而更新。

Listof不支持更改通知。出于您的目的,请将Listof更改为ObservableCollectionof。

List类未实现支持列表更改通知的IBindingList接口

请尝试改用该类:

提供支持数据绑定的通用集合

要观察类中属性的更改,该类需要实现接口:

通知客户端属性值已更改


@我将我的列表更新为绑定列表,它似乎起作用了。如果你把你的评论改成一个答案,我可以把它标记为已回答,并给你评分。现在我只需要解决我的线程问题!