如何过滤充满 MySqlDataAdapter 的 wpf gridview?
how to filter a wpf gridview that is filled with MySqlDataAdapter?
这是我的数据网格视图的填充方式:
using (MySqlDataAdapter a = new MySqlDataAdapter(query, conn))
{
DataTable dt = new DataTable();
a.FillAsync(dt);
dataGridView1.ItemsSource = dt.DefaultView;
}
现在我曾经以这种方式在 winforms 中过滤我的数据网格视图:
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = rowFilter;
这是它的 wpf 版本,它不起作用
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
((DataView)dataGridView1.ItemsSource).ToTable().DefaultView.RowFilter = rowFilter;
上面的 wpf 版本代码 运行正常但是它 不过滤 gridview 而是传递它(代码)就像什么都没发生?
最后,如何过滤我的 wpf datagridview?
P.S:在 xaml 方面,我既新又不擅长,这就是为什么我更喜欢 c# 代码解决方案。
感谢上帝...我找到了解决方案!!!
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
((DataView)dataGridView1.ItemsSource).RowFilter = rowFilter;
我使用的是 DefaultView.RowFilter 不起作用 而我应该使用 DataView.RowFilter(作品 喜欢魅力)。
对于任何新的行过滤,我认为这里是row filter cheat sheet。
这是我的数据网格视图的填充方式:
using (MySqlDataAdapter a = new MySqlDataAdapter(query, conn))
{
DataTable dt = new DataTable();
a.FillAsync(dt);
dataGridView1.ItemsSource = dt.DefaultView;
}
现在我曾经以这种方式在 winforms 中过滤我的数据网格视图:
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
(dataGridView1.DataSource as DataTable).DefaultView.RowFilter = rowFilter;
这是它的 wpf 版本,它不起作用
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
((DataView)dataGridView1.ItemsSource).ToTable().DefaultView.RowFilter = rowFilter;
上面的 wpf 版本代码 运行正常但是它 不过滤 gridview 而是传递它(代码)就像什么都没发生?
最后,如何过滤我的 wpf datagridview?
P.S:在 xaml 方面,我既新又不擅长,这就是为什么我更喜欢 c# 代码解决方案。
感谢上帝...我找到了解决方案!!!
string rowFilter = string.Format("[{0}] LIKE '%{1}%'", "full name", pattern);
((DataView)dataGridView1.ItemsSource).RowFilter = rowFilter;
我使用的是 DefaultView.RowFilter 不起作用 而我应该使用 DataView.RowFilter(作品 喜欢魅力)。
对于任何新的行过滤,我认为这里是row filter cheat sheet。