Answer to Question #38984 in C# for monalisa

Question #38984
The user should be able to view data stored to the customer details file.Write the code that Elina should use to read data to the customer details file and display it to the user.
1
Expert's answer
2014-05-01T11:41:24-0400
Answer on Question#38984-Programming, C#
1. The user shouldbe able to view data stored to the customer details file.Write the code that
Elina should use to read data to the customer details file and display it to
the user.

Solution.

using System;
usingSystem.Collections.Generic;
usingSystem.ComponentModel;
usingSystem.Data;
usingSystem.Drawing;
usingSystem.Linq;
usingSystem.Text;
usingSystem.IO;
usingSystem.Windows.Forms;

namespace QCSharp
{
public partial class Form1 : Form
{
publicForm1()
{
InitializeComponent();
}

privatevoid Form1_Load(objectsender, EventArgs e)
{
// Readeach line of the file into a string array. Each element
// of thearray is one line of the file.
string[] lines=null;
try
{
lines = System.IO.File.ReadAllLines(@"Detailsfile.txt");//d:\Projects\QCSharp\QCSharp\bin\Debug\Detailsfile.txt
}
catch{ System.Console.WriteLine("File not found!"); }

//Add toColumns
char[]delimiters = new char[]{ '*' };
string[]words = lines[0].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
foreach(string s inwords)
{
dataGridView1.Columns.Add(s.ToString(), s.ToString());
}
//Display the file contents by using a foreach loop.
System.Console.WriteLine("Contents of WriteLines2.txt = ");//Add to Rows
foreach(string line inlines)
{
words = line.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
dataGridView1.Rows.Add(words.ToArray());
}
}
}
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS