code不显示 datagridview的事情
为什么呢?
code does not display anything in datagridview
why?
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显示图片 https://m.xsw88.com/allimgs/daicuo/20230903/1633.png.jpg
大概需要这样的:
dataGridView1.DataBind();
右键后,您设置数据源。
Right after you set the data source.