views:

861

answers:

3

Hello! I have a datagridview with a number of columns, one of these is a datetime column. I want to display the rows from most recent downwards. e.g. Today Yesterday The Day Before Yesterday etc.

Is it possible to do this with the datagridview? The gridviews datasource is an xmldocument.......

help appreciated greatly.

Regards,

+1  A: 
 this.dataGridView1.Sort(dataGridView1.Columns["DateTime"], ListSortDirection.Ascending);
Goober
A: 

What is your datasource? You have to have a datasource that supports sorting.

e.g. a DataTable.

If you have a List you can't sort by default. In theory you need your on class that inherits from BindingList and implements IBindingList (inheritance from BindingList is not nessacary, but makes it a bit easier).

If your BingingList is bound to the DataGridView you can sort.

SchlaWiener
A: 

As far as I know, sorting is not supported for XML data sources. I think your best approach will be to first load the XmlDocument into a dataset and bind that to the grid.

Jamie Ide