C # datagridview row order?

I have a datagridview with multiple columns, one of which is a datetime column. I want to display rows from the very last down. e.g. Today Yesterday Day until yesterday, etc.

Is it possible to do this using datagridview? The gridviews data source is xmldocument .......

very grateful.

Hi,

+6
c # order datagridview
source share
3 answers
this.dataGridView1.Sort(dataGridView1.Columns["DateTime"], ListSortDirection.Ascending); 
+12
source share

What is your data source? You must have a data source that supports sorting.

eg. DataTable

If you have a List, you cannot sort by default. Theoretically, you need your class, which inherits from BindingList and implements IBindingList (inheriting from BindingList is not nessacary, but makes it a little easier).

If your BingingList is bound to a DataGridView, you can sort.

0
source share

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

0
source share

All Articles