使用多个复选框来datagrid来过滤数据 [英] The use of multiple checkbox to datagrid to filter data

查看:64
本文介绍了使用多个复选框来datagrid来过滤数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,对不起我的语言,翻译谷歌。



有一个DataGrid并填充如下:

Hi everyone, sorry for my language at once, translated Google.

There is a DataGrid and filled it like this:

dataGrid1.ItemsSource = dt.DefaultView;





按此方法过滤我:



Filter I by this method:

((DataView)dataGrid1.ItemsSource).RowFilter = "fname = 'fname1'";





如果我点击fname1,它只显示fname1

如果我点击fname2,它只显示fname2



当你点击fname1 fname2然后他展示了fname1和fname2时怎么做?



http://s020.radikal.ru/i715/1212/8d/c0d40af3a341.jpg



If I click on fname1, it only shows fname1
If I click on fname2, it only shows fname2

How to do that when you click on fname1 fname2 and he showed and fname1 and fname2?

http://s020.radikal.ru/i715/1212/8d/c0d40af3a341.jpg

推荐答案

示例


您好不明白。所以请改进你的问题
Hi Cant understand . So Pls improve your question


DataGrid我这样填写:

DataGrid I fill like this:
String strConnection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
            SqlConnection con = new SqlConnection(strConnection);
            con.Open();
            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter("Select * from RNames", con);
            SqlCommandBuilder cmd = new SqlCommandBuilder(da);
            da.Fill(dt);
            dataGrid1.ItemsSource = dt.DefaultView; 





在DataGrid中过滤如下:



Filtering in the DataGrid is as follows:

private void checkBox1_Checked(object sender, RoutedEventArgs e)
       {
     ((DataView)dataGrid1.ItemsSource).RowFilter = "fname = 'fname1'";
       }




private void checkBox2_Checked(object sender, RoutedEventArgs e)
       {
  ((DataView)dataGrid1.ItemsSource).RowFilter = "fname = 'fname2'";
       }





当你点击checkBox1和checkBox2时如何做到这一点,显示在

fname1 lname1

fname2 lname2



And how to do that when you click on checkBox1 and checkBox2, are displayed in the
fname1 lname1
fname2 lname2


这篇关于使用多个复选框来datagrid来过滤数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆