stojilcoviz,
The data grid needs a "list" that implements the IBindingList interface,
specifically IBindingList.SupportsSorting, IBindingList.SortDirection,
IBindingList.SortProperty, IBindingList.ApplySort, IBindingList.RemoveSort,
and IBindingList.IsSorted. One such class is the DataView class. Another is
the classes found in CSLA .NET
http://www.lhotka.net/
Unfortunately ArrayList itself does not implement IBindingList. With effort
one could create a class that implements a IBindingList wrapper over an
ArrayList. One of the projects I've worked on we took such an approach,
unfortunately I don't have a sample of that code readily available.
Lhotka's book "Expert One-on-One - Visual Basic .NET Business Objects"
covers CSLA .NET & includes an example of implementing IBindingList that
supports sorting. NOTE: You can download the source to CSLA .NET at the
above site.
Hope this helps
Jay
"stojilcoviz" <stojilcoviz_leavethisout_@libero.it> wrote in message
news:Xns9629B4B61E00Cstojilcovizliberoit@193.70.192.192...
| <(E-Mail Removed)> wrote in
| news:5B6F05DE-33F8-40A0-BEE7-(E-Mail Removed):
|
| This would be a solution.
| I hoped that grid sorting could be handled like for datatables (i.e. you
| click the column header and the grid is sorted based on the column you
| clicked).
|
| Can somebody confirm that this doesn't work on datagrid with arraylist as
| datasource?
|
|
| > Assuming that the datagrid is displaying the arraylist items in the
| > order that they exist in the arraylist, you can use the datagrid's
| > CurrentRowIndex as an index to the arraylist's Item property. This
| > will let you obtain a reference to the object in the arraylist.
| >
| > You could sort the datagrid by sorting the arraylist.
| >
| >> I've a datagrid whose datasource is an arraylist object. The
| >> arraylist holds many instances of a specific class.
| >>
| >> I've two questions about this:
| >> 1 - Is there a way by which I can obtain a reference to the arraylist
| >> item
| >> the current row points to?
| >> 2 - Is it possible to sort the grid?
| >>
| >> Many thanks in advance.
|