Copy/Pasting? More like reading CSV from a stream ?
Create a Model aka a class to store the values once you start reading the CSV using any sort of stream reader. As you read the positions of the fields from the CSV you can start storing them into your model and then it is easy from there. You might want to think about reading everything into a List, so you only read once.
Here is your class
public class Model
{
public string InvoiceNumber { get; set; }
...
}
Here is the CSV reading piece
using (StreamReader sr = new StreamReader(sourceFileName))
{
List<Model> modelList = new List<Model>();
string headerLine = sr.ReadLine();
string currentLine;
for (int i = 0; i < strArray.Length; i++)
{
while ((currentLine = sr.ReadLine()) != null)
{
string[] strArray = currentLine.Split(',');
Model myModel = new Model();
switch (i)
{
case 0: myModel.InvoiceNumber = = strArray[i]; break;
case 1: myModel.InvoiceHeaderId = strArray[i]; break;
}
}
}
modelList.Add(myModel);
}
}
From Here you can assign this to the UI.It depends which row you want to read, maybe filter the result to get the id, or filter my other pieces of data. Up to you to decide, you can add those filters in the for each loop. Or even better, take a look at LINQ. :D
foreach (var item in modelList)
{
txtInvoiceNumber.Text = mymodel.InvoiceNumber;
txtinvoiceHeaderId.Text = mymodel.InvoiceHeaderId;
}