private void NextCar(object sender, EventArgs e) { //Init Auto newAuto = registerHandler.GetNextCar(currentID); Malli_cBox.Items.Clear(); ID_Label.Text = "ID: " + newAuto.Id; currentID = newAuto.Id; //Textfield values hinta.Text = newAuto.Hinta.ToString(); paivamaara_Picker.Value = new DateTime(newAuto.Rekisteri_paivamaara.Year, newAuto.Rekisteri_paivamaara.Month, newAuto.Rekisteri_paivamaara.Day); tilavuus.Text = newAuto.Moottorin_tilavuus.ToString(); mittarilukema.Text = newAuto.Mittarilukema.ToString(); Merkki_cBox.SelectedIndex = newAuto.AutonMerkkiID - 1; AutonMalli[] models = registerHandler.getAutoModels(newAuto.AutonMerkkiID).ToArray(); foreach (AutonMalli malli in models) { Malli_cBox.Items.Add(malli); } Malli_cBox.DisplayMember = "MalliNimi"; foreach (AutonMalli malli in models) { if (malli.Id == newAuto.AutonMalliID) { Malli_cBox.SelectedItem = malli; break; } } Malli_cBox.SelectedValue = newAuto.AutonMalliID.ToString(); fuel_cBox.SelectedIndex = newAuto.PolttoaineID - 1; color_cBox.SelectedIndex = newAuto.VaritID - 1; }