I have created an application in C#. I want to display the text in the text file separated by commas in a DataRow or a GridView.
I am using this code to display the text in a listbox
private void button1_Click(object sender, EventArgs e)
{
var file = File.OpenText("C:\\File.txt");
string line;
bool flag = true;
while ((line = file.ReadLine()) != null)
{
listBox1.Items.Add(new { srno= line, Date= "descr", Time= DateTime.Now ,symbol = Symbol });
}
}
But its not well for others to understand what its displaying.i want to display something like this
check this link https://i.stack.imgur.com/LEmdz.jpg
There would be great appreciation if someone could help me.
Thanks In Advance.
Silly me looks like this is WinForms not asp.net. Got retagged. I’ll leave this here for someone else then.
You’ll want to turn the file in to a
DataTable. There is a decent example of this at http://www.akamarketing.com/blog/256-csv-datatable.htmlIt’s more of a generic approach than anything.
Here is an untested example you could try to work through.