StreamReader in Windows Application

Dec 13 2007 2:45 AM

so far here are my codes... thanks for the help

however, there are still glitches in the process

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


// add private fields
private string[] lines;
private int nextLine = 0;


        private void frmCustomerDetails_Load(object sender, EventArgs e)
        {

            //Reads records from a file


            lines = File.ReadAllLines(@"C:\mp2.txt");
            DisplayRecord(0);

        }

        private void DisplayRecord(int index)
        {
                string[] records = lines[index].Split('#');
                txtCustomerID.Text = records[0];
                txtContactPerson.Text = records[1];
                txtAddress.Text = records[2];
                txtContactPerson.Text = records[3];
                txtContactNo.Text = records[4];
                if (index < lines.Count - 1) nextLine = 
 index + 1;

         //  lines.Count didn't worked (System.Array doesn't not contain a definition

           //  for 'Count'


        }


        private void btnFirst_Click( object sender, EventArgs e)
        {
             DisplayRecord(0);
        }

        private void btnNext_Click( object sender, EventArgs e)
        {
              DisplayRecord(nextLine);   
        }

 

I also added two more features, but I don't where to start:

         // btnPrev - Displays records before the 2nd, 3rd, 4th......

        private void btnPrev_Click( object sender, EventArgs e)
        {
             // What to write?

        }

 

         // btnLast - Displays the last record in the .txt file

        private void btnLast_Click( object sender, EventArgs e)
        {
             // What to write?
        }


Answers (1)