问题描述
你好!
从lasttopic我有关于过滤行DataGridView的问题。
这是关于主题的链接,在这里你可以看到形状DataGrig:
Hello!
From lasttopic i have question about filtering rows DataGridView.
This is link on topic, where you can see how shapes DataGrig:
ListCards.DataSource = BLL.Cards.GetListCards(); (View layer)
手动MSDN我发现以下内容:
At manual MSDN i found following:
BindingSource bs = new BindingSource();
bs.DataSource = dataGridView1.DataSource;
bs.Filter = "yourColumnName like '%" + textBox1.Text + "%'";
dataGridView1.DataSource = bs;
_________________________________
在第一个我想填充网格并显示它:ListCards.DataSource = BLL.Cards.GetListCards();
当我向TextBox输入文本时,我想按名称网格进行排序以及如何制作它?
试试这样:
BindingSource bs = new BindingSource();
_________________________________
In the first i want to fill Grid and show it: ListCards.DataSource = BLL.Cards.GetListCards();
When i enter text to TextBox i want to do sort by Name Grid and how make it?
Try such:
BindingSource bs = new BindingSource();
<pre lang="c#">
....活动
bs.DataSource = BLL.Cards.GetListCards();
bs.Filter =yourColumnName like''%+ textBox1.Text +%'';
ListCards.DataSource = bs;
....Event
bs.DataSource = BLL.Cards.GetListCards();
bs.Filter = "yourColumnName like ''%" + textBox1.Text + "%''";
ListCards.DataSource = bs;
推荐答案
BindingList<Cards.Model.Cards> filtered = new BindingList<Cards.Model.Cards>(list.Where(
p => p.Username.Contains(""+textBox1.Text+"")).ToList());
ListCards.DataSource = filtered;
这篇关于如何过滤Datagridview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!