我有 BindingSource 和 Dictionary 两个对象。BindingSource 对象包含List of Vehicles 类对象的对象,Dictionary 对象包含BindingSource 类对象。这是全局声明:
Dim bs As BindingSource
Dim dicBinding As Dictionary(Of Integer,BindingSource)
当用户单击名为“添加”的按钮时,我将车辆类的对象添加到 bs,然后将 bs 添加到 dicBinding:
If bs Is Nothing Then bs = New BindingSource(New List(Of Vehicle),Nothing)
If dicBinding is Nothing Then dicBinding = New Dictionary(Of integer,BindingSource)
Dim i As Integer = dicBinding.Count
dicBinding.Add(i,bs)
当我想从 dicBinding 对象中检索 BindingSource 对象时:
bs =TryCast(dicBinding.Item(0),BindingSource)
For Each v As Vehicle In bs.List
MessageBox.Show(v.VehicleId)
Next
但我无法找回。有人可以帮我吗?