ArrayLists and Datagrids

  • Thread starter Thread starter scorpion53061
  • Start date Start date
S

scorpion53061

I would like a suggestions on the best way to write 2 arraylists to a
datagrid or if it is even possible.

I would want to do AList.Item(0) = BList.Item(0) and trying to write them
both to a datagrid in seperate columns.
i was thinking about writing the arrays to a datatable in code and writing
that to the grid but I though that would be expensive.
 
scorpion53061,
Instead of the overhead of a DataTable, I would consider creating one or two
proxy objects, and binding to that. (you still have overhead, but not as
much).

I would define a proxy object that represented a single row of your array
lists

Public Class Item

Public A As Object ' actually properties
Public B As Object

Public Sub New(a As Object, b As Object)
Me.A = a
Me.B = b
End Sub

End Class

Then I would populate an arraylist with the above items.

' VS.NET 2003 syntax
Dim list As New ArrayList(AList.Count)
For index As Integer = 0 to AList.Count - 1
list.Add(New Item(AList(index), BList(index)))
Next

Then I would bind to 'list'.

Instead of using an ArrayList above I would consider creating a class
derived from CollectionBase, that accepted AList & BList as parameters to
the constructor and built the list based on that...

Hope this helps
Jay
 
Back
Top