kerseub wrote:
Hibernate version: 1.2.0.4000 Mapping documents: really usefull here ?Name and version of the database you are using: SQL Server 2005Hi everyone, I'm using the CreateCriteria Method to create an IList.
Then I cast this IList to an ArrayList which is finally specified as datasource to a DataGridView. Clearly :
Code:
ArrayList liste = (ArrayList)this._session.CreateCriteria(typeof(MyWonderObject)).List();
dataGridView1.datasource=liste
Then the list is displayed correctly (that is not so bad) but it is impossible to sort it on another Column with a clic on a ColumnHeader.
Could you explain me why? How could I give an Iset as a datadource AND keep the datagrid's sort functionalities?
P.S.: MyWonderObject is already Implementing Equals() and compareTo() methods.
Thanks in advance.
Kerseub
The datagridview only supports sorting datatables or dataviews if i recall correctly. Create a List based on your ISet (just pass it to the constructor... it implements IEnumerable so the List constructor will accept it) and then you can use Mark Brooks' DynamicComparer to easily (and very efficiently) sort the list based on the sortexpression of the DataGridView.
You can find an example of how to use the DynamicComparer here:
http://ralinx.wordpress.com/2007/07/02/ ... f-objects/
it provides very fast sorting and you don't have to do anything for it... it's very nice. All you need to do is implement the sort method of the DataGridView (or is it the sort method of the ObjectDataSource... i'm not sure on that one)... you can simply pass the sortexpression from the DataGridView to the DynamicComparer and the list will be sorted nicely.