private void SaveListHandler(object sender, EventArgs e) { ListAdder la = sender as ListAdder; if (la != null) { UserDictsEventArgs dictargs = new UserDictsEventArgs(); dictargs.Name = la.CurName; dictargs.Words = la.CurList; AddUserDict?.Invoke(this, dictargs); foreach (var control in queryPanel.Controls) { var button = control as Button; if (button.Text.Contains("haswordofdict")) { ToolStripMenuItem item = new ToolStripMenuItem(la.CurName); item.Name = la.CurName; item.Click += MenuStripItem_Click; button.ContextMenuStrip.Items.Add(item); } } var temp = new ListViewItem(la.CurName); temp.SubItems.Add(String.Join(", ", la.CurList.ToArray())); listView1.Items.Add(temp); } la.Close(); }
private void listButton_Click(object sender, EventArgs e) { ListAdder la = new ListAdder(); la.SaveList += new EventHandler(SaveListHandler); la.Show(); }