Importing ascii file into DataGrid in C# WPF
Posted
by heckler
on Stack Overflow
See other posts from Stack Overflow
or by heckler
Published on 2010-05-12T18:58:57Z
Indexed on
2010/05/12
19:04 UTC
Read the original article
Hit count: 215
Hi, I just started programming in C# and using WPF so pardon my ignorance. I'm creating an WPF application where I need to dynamically make a grid. The grid headers will be different every time based on information in the text file and I will only need this grid if the user opens it.
So right now, I'm able to brows for a file and get the path. Then after I create a datagrid, like this:
//Create a new data grid
DataGrid datagrid1 = new DataGrid();
Master.Children.Add(datagrid1);
Grid.SetRow(datagrid1, 1);
Grid.SetColumn(datagrid1, 1);
Now, I have issues accessing the file and populating the grid. How would I be able to do this in C#?
The file will first have this header:
Time x y speed_x speed_y acc_x acc_y Target Leg Type
The header can have more paramaters depending on the file.
then it will have an unknown amount of row of data like this:
0.00 47.50 -42.50 -1.00 0.00 0.00 0.00 1 1 Sensor_1
© Stack Overflow or respective owner