stojilcoviz,
The data grid needs a "list" that implements the IBindingList interface,
specifically IBindingList.Su pportsSorting, IBindingList.So rtDirection,
IBindingList.So rtProperty, IBindingList.Ap plySort, IBindingList.Re moveSort,
and IBindingList.Is Sorted. 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
"stojilcovi z" <st************ ***********@lib ero.it> wrote in message
news:Xn******** *************** **********@193. 70.192.192...
| <Ke**********@d iscussions.micr osoft.com> wrote in
| news:5B******** *************** ***********@mic rosoft.com:
|
| 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.
|