public static void Studenci(string textBox) { List <string> dane = CzytaniePliku.Plik(); Window3 w3 = new Window3(); foreach (var VARIABLE in dane) { if (VARIABLE == textBox) { for (int i = 0; i < 4; i++) { w3.label.Content += dane[i]; w3.label.Content += " "; } } } if (w3.label.Content == string.Empty) { MessageBox.Show("Error"); } else { w3.Show(); } }
private void button_Click(object sender, RoutedEventArgs e) { try { if (!String.IsNullOrWhiteSpace(textBox.Text)) { CzytaniePliku.Plik(); CzytaniePliku.Studenci(textBox.Text); } } catch (Exception ex) { MessageBox.Show(this, ex.Message, "Błąd", MessageBoxButton.OK, MessageBoxImage.Error); } }