Click here to Skip to main content
14,865,273 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone know how to load a DataGrid with a csv file? In Winforms it was quite easy by means of dg.Rows.Add({object()}). This method is not available in the Silverlight DataGrid. If there is another approach to displaying this kind of data I am open to suggestions.

The trick here that I need it to be dynamic. Open any csv file of diff number of columns without prior knowledge.

Searching - yeah my tail off, nothing matches my criteria.

My attempt:

VB
Dim ofd As New OpenFileDialog
     If ofd.ShowDialog Then
       If IO.File.Exists(ofd.File.FullName) Then
         Dim srsCol As New List(Of String())
         Using fs As IO.FileStream = ofd.File.OpenRead
           Using sr As New IO.StreamReader(fs)
             While Not sr.Peek = -1
               srsCol.Add((sr.ReadLine.Split(","c).ToArray))
             End While
           End Using
         End Using
         dgStaff.ItemsSource = srsCol
       End If
     End If
Posted
Updated 12-Jun-13 4:13am
v3

What about your search in Google? Did you search on it, right?

Anyway, there is a great article here[^].

Best regards.
   
Comments
Idle_Force 12-Jun-13 10:14am
   
I have, I updated the question to be more clear.
I solved it and posted it in the discussions board on CodePlex since the solution involves using this extended DataGrid.

Bindable Datagrid
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900