Reputation: 289
I have a class :
class TermekRendeles
{
public int TermekID;
public string TermekNev;
public int Mennyiseg;
}
And a list of it:
List<TermekRendeles> TermekLista;
Which consists of data like:
1 | X | 2
2 | Y | 3
And I want it as a datasource of a DataGridView
(and it to show the data like above). I have been trying different ways, wanted it in a ListBox
first, but figured the DataGridView
would be easier, but still can't get it. Most recent try:
bindingSource1.DataSource = TermekLista;
dataGridView1.DataSource = bindingSource1;
But it just doesn't do anything, it stays a blank dgw. What am I doing wrong?
Upvotes: 3
Views: 73
Reputation: 81610
You have to use Properties, not Fields:
class TermekRendeles
{
public int TermekID {get; set;}
public string TermekNev {get; set;}
public int Mennyiseg {get; set;}
}
Upvotes: 2