c# - from where does the DataGridView get the columns names when associated with data source -


hello have linq query follow

var q = (from c in db.table1          select c).tolist(); 

then assign result datagridview

mydgv.datasource = q; 

the table1 before have: mycol1,mycol2,mycol3 columns

the grid view present data same columns names db table

the question did names?

i assigned collection data source nothing more

are using entity model? if when create model generates classes each table including properties match of table columns database. when set datasource list of these objects automatically assign property name grid view well.

you can use headertext property of datagridview specify custom text column headers if properties aren't liking:

msdn article


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -