private void editGroupToolStripMenuItem_Click(object sender, EventArgs e) { if (grouplist.SelectedItem != null) { //string oldname = grouplist.SelectedItem.ToString (); //grouplist.SelectedItem = oldname; int ind = grouplist.SelectedIndex; option_add_group lForm = new option_add_group(); lForm.Owner = this;//重要的一步,主要是使Form2的Owner指針指向Form1 lForm.CMD = "edit"; lForm.groupName = grouplist.SelectedItem.ToString(); lForm.ShowDialog(); if (reGroup != null) { grouplist.Items[ind] = reGroup; reContact = null; } } }
//↓↓↓↓↓↓↓↓↓↓ group list right menu ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ private void addGroupToolStripMenuItem_Click(object sender, EventArgs e) { grouplist.Items.Add("new group"); grouplist.SelectedItem = "new group"; int ind = grouplist.SelectedIndex; option_add_group lForm = new option_add_group(); lForm.Owner = this;//重要的一步,主要是使Form2的Owner指針指向Form1 lForm.CMD = "add"; lForm.groupName = "new group"; lForm.ShowDialog(); if (reGroup != null) { grouplist.Items[ind] = reGroup; reGroup = null; } }