Home Forums WinForms controls Xceed Grid for WinForms Filter on a DataSet

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #13860 |

    Hello,

    I’ve got this problem when trying to filter data rows in an xceed grid.

    The grid is connected to a dataset with 3 tables (a main table, which is displayed in the main grid and 2 secondary tables, displayed in 2 detail grids).

    I would like to filter the rows based on information in the main table. So what I tried to do is create a view of the main table and add it a RowFilter, like this :

    Private Sub FilterIntoDataGrid(ByVal strSearch As String)
    Dim dsSource As Object = Me.DataSource
    Dim dtSourceTable As Data.DataTable
    Dim dvGenericTable As Data.DataView

    dtSourceTable = dsSource.Tables(Me.DataMember)
    dvGenericTable = dtSourceTable.DefaultView()

    Try
    dvGenericTable.RowFilter = strRecherche
    Catch ex As Exception
    dvGenericTable.RowFilter = String.Empty
    End Try

    Me.Refresh()
    End Sub

    The result…nothing. No change in the grid whatsoever, even if the view contains no rows.

    Could anyone point me to a solution ? Thank you.
    Max

    Imported from legacy forums. Posted by AhileCelNegru (had 1973 views)

    User (Old forums)
    Member
    Post count: 23064

    I don’t think you should set a RowFilter on the DefaultView of a table. Instead, create a new DataView on top of the table, and set the DataSource of your grid to this view.<code>Dim dvFilteredView As DataView = New DataView(dsSource.Tables(“myTable”))
    myGrid.DataSource = dvFilteredView
    Private Sub FilterIntoDataGrid(ByVal strSearch As String)
    myGrid.BeginInit()
    Try
    dvFilteredView.RowFilter = strSearch
    Catch ex As Exception
    dvFilteredView.RowFilter = String.Empty
    Finally
    myGrid.EndInit()
    End Try
    End Sub</code>

    Imported from legacy forums. Posted by Tommy (had 3084 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.