public partial class Form1 : Form
{
BindingSource source;
public Form1()
{
InitializeComponent();
List<Source> list = new List<Source>();
list.Add(new Source
{
ID = "1",
Name = "c#"
});
list.Add(new Source
{
ID = "2",
Name = "JAVA"
});
source = new BindingSource();
source.DataSource = list;
this.dataGridView1.DataSource = source;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
source.Filter = " '%" + textBox1.Text.Trim().ToUpper() + "%'";
}
}
public class Source
{
public string ID { get; set; }
public string Name { get; set; }
}
Filter无效。。请问高手为什么??网上查了。必须用datatable或dataset做数据源。。如果非要用list。。。要怎么处理??神人进。。。
就用datatable怎么了?list转成datatable又不麻烦