Sorted output from datagrid 
Author Message
 Sorted output from datagrid

Say I fill a dataset and bind its table to a datagrid.  After sorting the
data using the datagrid's column headers, I'd like to iterate each row of
the datagrid in the sorted order.  Iterating the rows of the underlying
table gives me the rows in the original order, so that's no good.  Any tips?


Wed, 21 Sep 2005 12:47:47 GMT  
 Sorted output from datagrid
Try getting the dataview from the CurrencyManager.List, and iterate through
the Row property there.

    Dim cm As CurrencyManager = Me.BindingContext(Me.DataGrid1.DataSource,
Me.DataGrid1.DataMember)
    Dim dv As DataView = CType(cm.List, DataView)

    Dim i As Integer
    For i = 0 To dv.Count - 1
         Console.WriteLine(dv(i).Row(0).ToString() + "  " +
dv(i).Row(1).ToString())
    Next

======================
Clay Burch, .NET MVP

Visit www.syncfusion.com for the coolest tools


Quote:
> Say I fill a dataset and bind its table to a datagrid.  After sorting the
> data using the datagrid's column headers, I'd like to iterate each row of
> the datagrid in the sorted order.  Iterating the rows of the underlying
> table gives me the rows in the original order, so that's no good.  Any
tips?



Thu, 22 Sep 2005 04:28:28 GMT  
 Sorted output from datagrid
That worked perfectly.  Thanks for your help.


Quote:
> Try getting the dataview from the CurrencyManager.List, and iterate
through
> the Row property there.

>     Dim cm As CurrencyManager = Me.BindingContext(Me.DataGrid1.DataSource,
> Me.DataGrid1.DataMember)
>     Dim dv As DataView = CType(cm.List, DataView)

>     Dim i As Integer
>     For i = 0 To dv.Count - 1
>          Console.WriteLine(dv(i).Row(0).ToString() + "  " +
> dv(i).Row(1).ToString())
>     Next

> ======================
> Clay Burch, .NET MVP

> Visit www.syncfusion.com for the coolest tools



> > Say I fill a dataset and bind its table to a datagrid.  After sorting
the
> > data using the datagrid's column headers, I'd like to iterate each row
of
> > the datagrid in the sorted order.  Iterating the rows of the underlying
> > table gives me the rows in the original order, so that's no good.  Any
> tips?



Fri, 23 Sep 2005 08:50:13 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Need some help with DataGrids (DataGrid-->DataGrid, DataGrid-->Dataset, DataGrid-->XML)

2. EXAMPLE: DataGrid Checkbox based on modifying output of Data Form Wizard

3. EXAMPLE: DataGrid Checkbox based on modifying output of Data Form Wizard

4. datagrid sorting

5. datagrid sorting

6. Custom sorting of datagrid

7. Sorting problem in DataGrid

8. sort event handler for dynamically created datagrid

9. Problem in finding right record in dataset after sorting datagrid

10. Currencymanager, datagrid and sort

11. Datagrid sorting and grouping

12. DataGrid & Sorting

 

 
Powered by phpBB® Forum Software