just having some small issues with c# winforms datagridview. Here's my scenario
I am using entity framework and am trying to bind certain entity models to my datagridview datasource.
var query = from q in context.foo
select q;
dgv_Disp.DataSource = query.ToList();
When I ran this piece of code above on a form class which had a datagridview in the GUI, it all worked fine. The datagridview will automatically generate columns and the number of rows.
But when I run this exact same code with the exception that I don't have a datagridview in the GUI, I just declare it programmatically and then set the datasource like the above code. And when I do it this way, no rows or columns are generated.
What is the difference between these two different datagridviews? I know that there are properties set in the designer.cs file of the form class. But I tried copying these settings and it still won't populate.
I know it's probably something simple but I just can't figure this out at all. If someone could show me what im doing wrong, that'd be great!
Edit
I have used AutoGenerateColumns = true but it didn't make any difference. Also I'm not actually trying to display this datagridview, I was just binding it to entity objects that way I could access its members using a string index. But I dont want to query the database just to get my info in a datagridview specific format because in my actual scenario, I already have my entity data from a previous query. I was just using the above code as an example.