我用数据表填充了数据网格。我可以用rowfilter过滤这个数据表。我搜索产品并获得结果。但是我也希望得到同一组中的其他产品。
我的代码
<Window x:Class="Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="129" Width="124" Loaded="Window_Loaded_1">
<Grid>
<DataGrid x:Name="testGrid" ItemsSource="{Binding}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding GROUP}" Header="GROUP"/>
<DataGridTextColumn Binding="{Binding PRODUCT}" Header="PRODUCT"/>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>
Private Sub Window_Loaded_1(sender As Object, e As RoutedEventArgs)
'Create tabel
Dim table As New DataTable
table.Columns.Add("GROUP", GetType(String))
table.Columns.Add("PRODUCT", GetType(String))
table.Rows.Add("Group1", "Printserver")
table.Rows.Add("Group1", "Recupel")
table.Rows.Add("Group2", "Docking")
table.Rows.Add("Group2", "Monitor")
'Set Filter
table.DefaultView.RowFilter = "PRODUCT like '%Monitor%'"
'Fill Datagrid
testGrid.DataContext = table
End Sub
以下是我需要的屏幕截图:
这将是===&gt;
如何使用数据表过滤器执行此操作?