I'm reading each line of a file into an array of strings:
string[] lines = File.ReadAllLines(filePath);
Each line is separated by a tab
lines[0] = "John\tPizza\tRed\tApple"
I want to load this string array into a DataGridView. I tried the following:
DataTable dt = new DataTable();
dt.Columns.Add("Name",typeof(string));
dt.Columns.Add("Food",typeof(string));
dt.Columns.Add("Color",typeof(string));
dt.Columns.Add("Fruit",typeof(string));
foreach(string s in lines)
{
dt.Rows.Add(s);
}
myDataGridView.DataSource = dt;
The problem is that all the strings are loaded to the first column of the DataGrid:
I need them to be separated like this:


dt.Rows.Add(s);