1

データグリッドをデータテーブルで埋めました。このデータテーブルを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

必要なもののスクリーンショットは次のとおりです。

私が得るものこれは ===> 私が必要なもの

データテーブルフィルターでこれを行うにはどうすればよいですか?

4

0 に答える 0