views:

26

answers:

1

I have a DataGridView (WinForms) populated with a relatively large table, using a DataTable as the DataSource. When the user clicks a column header, sorting starts and this is desired. However, the sorting takes a while and I would like to allow the user to abort the operation: A button is displayed that the user would click to abort the operation. It this possible? If so, how?

A: 

Not aborting but see this post for improving DataGrid's sorting performance: http://blogs.msdn.com/b/jgoldb/archive/2008/08/26/improving-microsoft-datagrid-ctp-sorting-performance.aspx

Or you can extract out the sorting mechanism, and run it in a background thread which can be cancelled. That way the UI won't hang up, and the user won't feel to cancel it. To add some spice, you can add a progress bar that notifies the user about sorting progress.

chown
My question is about the WinForms DataGridView, not the WPF DataGrid. I find that sorting of 200k rows takes seconds, not minutes. This may be different for the WPF DataGrid.
ILoveFortran