首页 新闻 会员 周边

winform高手进...

0
[已解决问题] 解决于 2012-12-20 00:48

    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。。。要怎么处理??神人进。。。

彬彬@科比的主页 彬彬@科比 | 初学一级 | 园豆:43
提问于:2012-12-18 21:55
< >
分享
最佳答案
0

就用datatable怎么了?list转成datatable又不麻烦

奖励园豆:5
茂茂 | 老鸟四级 |园豆:2892 | 2012-12-19 09:46
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册