/** * This method defines what happens when the listbox is doubleclicked */ private void listBox1_DoubleClick(object sender, EventArgs e) { try { if (listBox1.Items.Count == 0) { throw new Exception("No salesman has selected. \nPlease search for salesman or click 'View All'"); } else { var edit = new EditSalesman(); edit.Show(this); this.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/** * This method defines what happens you double click a member in viewing list box */ private void listBox1_DoubleClick(object sender, EventArgs e) { try { if (ViewinglistBox.Items.Count == 0) { throw new Exception("No salesman has selected. \nPlease Select a team or region or search for team"); //check if items are in listbox } if (ViewinglistBox.SelectedIndex < 0) { throw new Exception("Select a salesman");//check if person is clicked } else { EditSalesman edit = new EditSalesman(); edit.Show(this);//show edit salesman form this.Hide(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }