I've been stuck on this problem for a little while now. I'm able to read information from a bunch (100) Textboxes and save the data into a CSV file but reading that information back into the form has me a little befuddled, I'm only trying to load the first 11 strings to start with. I can load the CSV into a List but I can't seem to move that data from the list to my Textboxes. Is there something I'm missing with my approach?
public List<string> LoadCsvFile(string filePath)
{
var reader = new StreamReader(File.OpenRead(filePath));
List<string> searchList = new List<string>();
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
searchList.Add(line);
for (int i = 0; i < 11; i++)
{
string date = searchList[i];
string dropdownindex = searchList[i];
LasttextBox.Text = searchList[i];
FirsttextBox.Text = searchList[i];
EmailtextBox.Text = searchList[i];
PhonetextBox.Text = searchList[i];
HometextBox.Text = searchList[i];
InfotextBox.Text = searchList[i];
PrimarytextBox.Text = searchList[i];
EmailtextBox.Text = searchList[i];
SecondaryEmailtextBox.Text = searchList[i];
}
}
return searchList;
}
The error I'm getting is:
System.ArgumentOutOfRangeException: 'Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index'
I appreciate any help you can provide.