Filter a DataGrid on a Text box

前端 未结 4 1977
挽巷
挽巷 2020-12-03 01:12

I search an example or sample to filter the WPF DataGrid column elements by a textbox.

\"alt

S

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-03 02:06

    I have seen at various sites much ado about this matter...

    To filter the latter being a datagrid using a datatable as the source, which is quite common to make the code below:

    DataTable dt = new DataTable("Table1");
    
    //fill your datatable...
    
    //after fill...
    dataGrid1.DataContext = dt;
    IBindingListView blv = dt.DefaultView;
    blv.Filter = "NAME = 'MOISES'";
    

提交回复
热议问题