I have a C# program that I am reading a CSV file with. using StreamReader, I populate the combo box with the contents of the CSV. The CSV contains 4 fields. I only want to display the 1st value in the selected line. I then want to pass 2 of the other fields to another process (I'm trying to map a network printer by location). Here's the part where I read the CSV.
try
{
    // Open the CSV file to read
    StreamReader sr = new StreamReader(printerList);
    String currentline = sr.ReadLine();
    while (!sr.EndOfStream)
    {
        currentline = sr.ReadLine(); 
        comboBoxPrinterList.Items.Add(currentline);
    }
}
catch (Exception ex)
{
    // Display an error message if the file cannot be read
    MessageBox.Show("The file could not be read" + ex.Message);
}
This works perfectly. The only thing is the line is so long it's not readable. End users will just select the location, which is the 1st field.
for testing I used this code to display the result
int selectedIndex = comboBoxPrinterList.SelectedIndex;
Object selectedItem = comboBoxPrinterList.SelectedItem;
MessageBox.Show("Selected Item Text: " + selectedItem.ToString() + "\n" +
                "Index: " + selectedIndex.ToString());
Is there a way to display only the 1st field in the combo box but still use the index number passed from the combo box control? I was thinking of creating an array of just the 1st field but do not know how I could reference the array AND the combo box index.
Any help is mucho appreciado....
 
     
    