Dev GridControl表格筛选排序后保存

dv1 = CType(GridView1.DataSource, DataView)
        dv1.RowFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(GridView1.ActiveFilterCriteria)
        dt1 = dv1.ToTable("MyDataTable2")
        GridControl2.DataSource = dt1

这种方式可以得到在gridcontrol上过滤后的数据,但是排序后的数据不行

另一种方式可以得到在gridcontrol上过滤和排序后的数据

 Dim _dt As New DataTable
        Dim dt_ As New DataTable
        _dt = GridControl1.DataSource
        If (_dt.Rows.Count = 0) Then
            MessageBox.Show("表为空!")
        End If

        dt_ = _dt.Clone()
        Dim i As Integer
        For i = 0 To GridView1.RowCount - 1

            If (GridView1.IsGroupRow(i)) Then
                Continue For
            End If
            Dim dr As DataRow
            dr = GridView1.GetDataRow(i)

            dt_.Rows.Add(dr.ItemArray)
        Next

        GridControl4.DataSource = dt_

你可能感兴趣的:(c#)