private void tsmiEditNameGroup_Click(object sender, EventArgs e) { var lv = GetListViewFromToolStripDropDownItem(sender); if (lv.SelectedItems.Count != 1) { return; } var item = lv.SelectedItems[0]; var data = (NameGroupData) item.Tag; using (var frm = new frmNameGroup(data)) { if (frm.ShowDialog() != DialogResult.OK) { return; } data.Name = frm.NameValue; data.Group = frm.GroupValue; item.SubItems[0].Text = data.Name; item.SubItems[1].Text = data.Group; } }
private void tsmiAddNameGroup_Click(object sender, EventArgs e) { var lv = GetListViewFromToolStripDropDownItem(sender); using (var frm = new frmNameGroup()) { if (frm.ShowDialog() != DialogResult.OK) { return; } var nameGroup = new NameGroupData { Name = frm.NameValue, Group = frm.GroupValue }; var item = new ListViewItem(nameGroup.Name) { Tag = nameGroup }; item.SubItems.Add(nameGroup.Group); lv.Items.Add(item); } }