private void internationalStudentCheckBoxSelected(object sender, RoutedEventArgs e) { // Allow student to internation student to select the country comboBoxesValidation(); if (chkTrue is CheckBox) { CheckBox internationalStudentCheckBox = (CheckBox)chkTrue; //Check if a student is an internation student if (internationalStudentCheckBox.IsChecked == true) { // Show the label and listbox for the selection of the country lblCountry.Visibility = Visibility.Visible; lblCountry.UpdateLayout(); ComboBoxCountry.Visibility = Visibility.Visible; ComboBoxCountry.UpdateLayout(); string CityFilelist = "CityList.txt"; try { string line = ""; // Read city names from the CityList and add it to the listBox System.IO.StreamReader file = new System.IO.StreamReader(CityFilelist); while ((line = file.ReadLine()) != null) { ComboBoxCountry.Items.Add(line); } ComboBoxCountry.UpdateLayout(); } catch (Exception) { MessageBox.Show("Error during dynamic creation of the listBox for country"); } } } }
private void nonInternationStudentCheckedSelected(object sender, RoutedEventArgs e) { //Add label and Listbox for Country Selection lblCountry.Visibility = Visibility.Hidden; lblCountry.UpdateLayout(); ComboBoxCountry.Visibility = Visibility.Hidden; ComboBoxCountry.UpdateLayout(); comboBoxesValidation(); }
void ButtonClear(object sender, RoutedEventArgs e) { // Unset textboxes of the form txtName.Text = " "; txtSurname.Text = " "; txtAddres1.Text = " "; txtAddres2.Text = " "; txtCity.Text = " "; txtPostcode.Text = " "; txtEmail.Text = " "; txtAge.Text = " "; //unset visibility label and listBox for the country selection lblCountry.Visibility = Visibility.Hidden; lblCountry.UpdateLayout(); ComboBoxCountry.Visibility = Visibility.Hidden; ComboBoxCountry.UpdateLayout(); //Unset Combobox for the course selection this.ComboBoxCourse.SelectedIndex = -1; // Unset checkboxes if checked if (chkFalse is CheckBox) { CheckBox nonInternationalStudentCheckBox = (CheckBox)chkFalse; if (nonInternationalStudentCheckBox.IsChecked == true) { nonInternationalStudentCheckBox.IsChecked = false; } } if (chkTrue is CheckBox) { CheckBox internationalStudentCheckBox = (CheckBox)chkTrue; if (internationalStudentCheckBox.IsChecked == true) { //unset comboBox internationalStudentCheckBox.IsChecked = false; } } }