private void AddFlightInfo(string flight, DateTime date, int Count) { Flight.Add(flight, date); FlightBaggageCount.Add(flight, Count); listBox.Items.Clear(); foreach (var item in Flight) { listBox.Items.Add(item.Key); } listBox.SelectedIndex = listBox.Items.Count - 1; }
private void DelectFlightInfo(string flight, int currIndex) { Flight.Remove(flight); FlightBaggageCount.Remove(flight); listBox.Items.Clear(); tbTime.Text = ""; foreach (var item in Flight) { listBox.Items.Add(item.Key); } if (listBox.Items.Count > 0) { if (currIndex - 1 >= 0) { listBox.SelectedIndex = currIndex - 1; } } }