Can I fill a Datagrid with a List<T>?

Asked

Viewed 537 times

3

How do I fill one DataGrid from a List typical?

It would be possible to generate the columns automatically?

  • To supplement your question, edit your question, not the answer given. To add an answer, give your own answer.

  • 1

    Caique, to complement the reply, leave a comment. The author decides whether or not to include the content you suggest.

  • Ah, okay. Sorry.

1 answer

3


Yes ItemSource of DataGrid (vi that your case is WPF) you can pass any enumeration (Ilist, Icollection, etc)

DataGrid1.ItemsSource = (new List<T>());

Where new List<T>() is your list.

To enable automatic column creation, place True in AutoGenerateColumns in his DataGrid of WPF.

  • 1

    Thanks man, it helped a lot. I did as I said and when I ran, nothing... I realized that there were three lines in Datagrid, but there was no column. I looked for some property or method that generated, found the Autogeneratecolumns and left as true and worked! Thanks :)

  • Okay, I’m glad it worked out

Browser other questions tagged

You are not signed in. Login or sign up in order to post.