I have a datagridview in my windows application. The user can click to sort columns and can move them around.
How do I obtain a datable (or similar container) with data in the same order?
Thanks.
I have a datagridview in my windows application. The user can click to sort columns and can move them around.
How do I obtain a datable (or similar container) with data in the same order?
Thanks.
Try
If that doesn't work you can find what the actual type of DataSource is. Then cast/as it on that and get that.Code:DataTable table = yourDataGridView.DataSource as DataTable;
Code:DataView view = yourDataGridView.DataSource as DataView; DataTable table = view.Table as DataTable; //not sure but something similar
Thanks for your response.
While this gives me the right data, it does not have it in the same order as the data grid view, if the user decides to rearrange the columns.
Is there anyway to account for this?
DataGridViewColumnCollection.itemssorted has what I need but is private. Any thoughts ((
Aha! This is what I did: I iterated through the Columns and used their DisplayIndex property to populate a list.
Last edited by euroazn; 08-18-2010 at 11:24 AM.