private void lstBoxAccessories_SelectedIndexChanged(object sender, EventArgs e) { if (lstBoxAccessories.SelectedIndex != -1) { int i = lstBoxAccessories.SelectedIndex; extras = extrasList[i]; } }
private void revealTheDataAccessories() { string queryString = "SELECT * FROM Tilbehør;"; DataTable dt = GetData(queryString); foreach (DataRow item in dt.Rows) { var theExtras = new Tilbehør(); theExtras.Id = Convert.ToInt32(item["Id"].ToString()); theExtras.EkstraTilbehør = item["Ekstra Tilbehør"].ToString(); theExtras.Price = Convert.ToDecimal(item["Price"].ToString()); extrasList.Add(theExtras); } lstBoxAccessories.ValueMember = "Id"; lstBoxAccessories.DisplayMember = "EkstraTilbehør"; lstBoxAccessories.DataSource = extrasList; }