private void tsmiEditJobTrigger_Click(object sender, EventArgs e) { var lv = GetListViewFromToolStripDropDownItem(sender); if (lv.SelectedItems.Count != 1) { return; } var item = lv.SelectedItems[0]; var job = (Job)item.Tag; using (var frm = new frmJob(job)) { if (frm.ShowDialog() != DialogResult.OK) { return; } item.Tag = frm.JobValue; item.SubItems[0].Text = frm.JobValue.Name; item.SubItems[1].Text = frm.JobValue.Group; } }
private void tsmiAddJobTrigger_Click(object sender, EventArgs e) { var lv = GetListViewFromToolStripDropDownItem(sender); using (var frm = new frmJob()) { if (frm.ShowDialog() != DialogResult.OK) { return; } var job = frm.JobValue; var item = new ListViewItem(job.Name) { Tag = job }; item.SubItems.Add(job.Group); lv.Items.Add(item); } }