private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { var comboBox = (ComboBox)sender; var satellites = comboBox.DataSource as List <Satellite>; if (satellites != null && comboBox.SelectedIndex > -1) { Satellite selectedSatellite = satellites[comboBox.SelectedIndex]; Console.WriteLine("Selected satellite: " + selectedSatellite.Name); } }
private void textBox1_TextChanged(object sender, EventArgs e) { var textBox = (TextBox)sender; string text = textBox.Text; if (!string.IsNullOrWhiteSpace(text)) { Satellite satellite = _satellites.FirstOrDefault((s => s.Name.ToLower().StartsWith(text.ToLower()))); if (satellite != null) { Console.WriteLine("Found satellite: " + satellite); } } }
private void textBox2_TextChanged(object sender, EventArgs e) { var textBox = (TextBox)sender; string text = textBox.Text; if (!string.IsNullOrWhiteSpace(text)) { Satellite satellite = _satellites.FirstOrDefault( s => s.Numbers1.Any(t => t.StartsWith(text)) || s.Numbers2.Any(t => t.StartsWith(text))); if (satellite != null) { Console.WriteLine("Found satellite: " + satellite); } } }