private void btnEdit_Click(object sender, EventArgs e) { //this checks to see if the listbox has a selected value if (LstBxSavedSearch.SelectedIndex > -1) { //this retrieves the Selected Item from the listBox on the EmailClient form string SavedSearchtext = LstBxSavedSearch.GetItemText(LstBxSavedSearch.SelectedItem); //this retrieves the Minimum age, the maximum age and the location via the Substring option available on the EmailClient form Int32 MinAge = Convert.ToInt32(SavedSearchtext.Substring(7, 2)); Int32 MaxAge = Convert.ToInt32(SavedSearchtext.Substring(10, 2)); string Location = SavedSearchtext.Substring(22); //this gets the new instance of the form Saved Search and it sends the Parameters to the Editsearch function //on the saved search form, displays the saved search form //then closes the current form (this is due to issues regarding showing the new listbox items on the listbox) FrmSavedSearch SavedSearch = new FrmSavedSearch(); SavedSearch.EditSearch(MinAge, MaxAge, Location); SavedSearch.Show(); this.Close(); } else { //this runs if user does not run selected item lblError.Text = "Please Select an item"; } }
private void btnAdd_Click(object sender, EventArgs e) { //this shows the Saved search form and closes the current form //(as the listbox doesn't properly refresh otherwise, due to persistent data) FrmSavedSearch NewSavedSearch = new FrmSavedSearch(); NewSavedSearch.Show(); this.Close(); }