Hi I require assistance on how to show browsing First, Next Previous and Last in C#. I need to split a text file with numerous records to show this information and I am struggling. If i could get a helping hand it would b much appreciated.

Thanks

Ryan

Read the text file records into an array or some other list data structure. Let's call it myList for this example.
Create a reference to the current record. Let's call it currentRecord for this example.
Create a reference (int) to the current record's index in the list. Let's call it currentIndex for this example.

Here is how I would write the First and Previous methods. Next is opposite of Previous and Last is opposite of First so I will leave them to you.

public void First()
{
  // make sure we can get the data
  if (myList.Count > 0)
  {
    // first index in the list is 0
    currentIndex = 0;
    currentRecord = myList[currentIndex];
  }
  else
  {
    currentIndex = -1; // -1 to indicate nothing selected
    currentRecord = null;
  }
}

public void Previous()
{
  // ensure we can get a previous record
  if (myList.Count > 0 && currentIndex > 0)
  {
     // decrement the current index and update the current record
     currentIndex--;
     currentRecord = myList[currentIndex];
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.