By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,573 Members | 1,786 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,573 IT Pros & Developers. It's quick & easy.

ArrayLists and Datagrids

P: n/a
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.

Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

"scorpion53061" <sc************@yahoo.com> wrote in message
news:eL**************@TK2MSFTNGP10.phx.gbl...
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.

Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.