I have a .csv file containing columns. I already have a form which allows the user to insert and save the information to this .csv file.
On a separate form, I created the ability to select items by their Item ID. I have a combobox which is displaying a drop down of Item IDs from the .csv file. Right now, the only Item IDs are 1000-1003.
    public void Items()
    {
        int itemID = 0;
        Inventory[] IArray = Inventory.getInv();
        for (int v = 0; v < IArray.Length; v++)
        {
            if (IArray[v] != null)
            {
                itID = IArray[v].getIID();
                Field.Items.Add(itID + "\r\n");
            }
        }
    }
When I select a certain Item ID, I would like to have my ReadOnly textboxes update with the appropriate Name/Discount/Price according to the file. The problem is, no matter what ID I choose, it's displaying the last line of the .csv file (right now the last line is Item ID 1003).
    private void Field_SelectedIndexChanged(object sender, EventArgs e)
    {
        string itName = "";
        double disc = 0;
        double price = 0;
        Inventory[] IArray = Inventory.getInv();
        for (int v = 0; v < IArray.Length; v++)
        {
            if (IArray[v] != null)
            {
                itName = IArray[v].getItName();
                disc = IArray[v].getDisc();
                price = IArray[v].getPrice();
                itNameS.Text = (itName);
                itPriceS.Text = Convert.ToString(price);
                itDiscountS.Text = Convert.ToString(disc);
            }
        }
    }
