There maybe a better way of doing this but I am attempting to display a
list of objects and their respective properties using a datagridview.
The object class is straight forward with several public properties.
Public Class myObj
Friend mID As String
Friend mData1 As String
Friend mData2 As String
Public Sub New(ByVal ID, ByVal Data1, ByVal Data2)
Me.mID = ID
Me.mData1 = Data1
Me.mData2 = Data2
End Sub
Public Property ID() As String
Get
ID = mID
End Get
Set(ByVal value As String)
mID = value
End Set
End Property
Public Property Data1() As String
Get
Data1 = mData1
End Get
Set(ByVal value As String)
mData1 = value
End Set
End Property
Public Property Data2() As String
Get
Data2 = mData2
End Get
Set(ByVal value As String)
mData2 = value
End Set
End Property
End Class
I generate a multitude of these objects and store them in a hash table.
Dim myHashtbl As New Hashtable()
Some Loop
myHashtbl.Add( ID, New myObj(ID, Data1, Data2))
End Loop
After I have done all of that, I would like to display the objects that
I stored in the hash table, within a DataGridView control. Where each
property is a Column and each instance of the object is a row. I was
able to assign the Datasouce to myObj, and the DataGridView picked up
all of the properties as columns. But I am unsure as how to populate the
grid with every object. Hopefully, this makes sense.
Thanks in advance!
Chuck
|