List<string> to Datagrid

Naxoscompact

Member
Joined
Mar 26, 2020
Messages
5
Programming Experience
Beginner
Hi,

I have a List<string> called DataOutput, which I obtained from converting a char array. (I know that it works as i have been able to write it to the output window.) I am trying to display it in a DataGrid either by binding in xaml or through the xaml.cs file.
1. how do i go about this?
2. is there a better way of outputting the list in a table type form?
3. should it be an ObservableCollection instead of a List? i have read that DataGrid should be populated from an IEnumerable type but i think that List<string> is??

(bonus question am i supposed to write something in the <> when creating a string type list besides 'string'. in my reading of various resources on this i have seen List<> with all sorts of words written between the <>.)

Any help appreciated.
 
If you have a single piece of data per row, since you have a string, why are you using a DataGrid? Why not just use a ListBox?

All List<T> implement IEnumerable<T>.
 
Why would you need gridlines? You are only displaying a single string. Please don't tell me that you actually have several columns of data for each string. If you do, you are doing things by being "stringly-typed". You want to be "strongly-typed". Use a List<CustomClass> instead and then use a DataGrid.
 
i have managed to make it work with a list and Data Grid. although it is one column i was instructed to insert the information in a table. Thanks for your help.
 
And what are the columns for your table?
 

Latest posts

Back
Top Bottom