0

为什么代码不显示任何内容datagridview

class classman
        {
            public int id;
            public string name;
        }

    private void Form2_Load(object sender, EventArgs e)
    {
        testtelContext db = new testtelContext();
        List<classman> qry = (from p in db.firstlasts
                             join i in db.firstnames
                                 on p.Idfname equals i.Idfname
                              select new classman
                             {
                                 id = p.idfl,
                                 name = i.fname

                             }).ToList();
      BindingSource bs=new BindingSource();
        bs.DataSource = qry;
        dataGridView1.DataSource = bs;

    }

bindingsource 有值但不显示 dataGridView5 显示图片http://irphoto.ir/uploads/13658793021.jpg

4

1 回答 1

3

大概需要这个:

dataGridView1.DataBind();

在您设置数据源之后。

于 2013-04-09T20:37:15.533 回答