我的应用程序上有一个datagrid从数据库中获取数据。这是通过将其放入数据表然后使用dataGrid1.ItemsSource = DT.DefaultView来显示它。使用文本框对WPF数据网格进行排序
我也有一个文本框将被用作搜索框。我希望搜索框搜索数据网格并显示正确的数据。根据用户输入到搜索框中显示的不仅仅是高光,而且实际上使数据消失或重新出现。
我有通过多个论坛搜索,但没有找到我的应用程序的解决方案。所以如果有人能给我一个解决方案,我会非常感激。
编辑,排序问题
Private Sub txtSearchBox_TextChanged(ByVal sender As System.Object, ByVal e As System.Windows.Controls.TextChangedEventArgs) Handles txtSearchBox.TextChanged
If txtSearchBox.Text = "" Then
dataGrid1.ItemsSource = DT.DefaultView 'puts the data in to the datagrid
DT.DefaultView.RowFilter = Nothing
Else
chosenFilter = txtSearchBox.Text
'sets the datagrid filter
DT.DefaultView.RowFilter = "TYPEID LIKE '%" & chosenFilter & "%'"
End If
End Sub
你能解释进一步请 – TeamGB