/// <summary> /// Edit an exclusion item. /// </summary> /// <param name="sender">system parameter</param> /// <param name="e">system parameter</param> private void btnEdit_Click(object sender, EventArgs e) { if (lstExclusions.SelectedItems.Count > 0) { // get currently selected exclusion var item = lstExclusions.SelectedItems[0].Tag as FilterItem; item.Enabled = lstExclusions.SelectedItems[0].Checked; var dlg = new frmAddEditExclusions(GetCurrentFilterItems(), item); if (dlg.ShowDialog(this) == DialogResult.OK) { item = dlg.CurrentItem; var listItem = GetListViewItem(item); lstExclusions.SelectedItems[0].Checked = item.Enabled; lstExclusions.SelectedItems[0].Tag = item; lstExclusions.SelectedItems[0].SubItems[1].Text = listItem.SubItems[1].Text; lstExclusions.SelectedItems[0].SubItems[2].Text = listItem.SubItems[2].Text; lstExclusions.SelectedItems[0].SubItems[3].Text = listItem.SubItems[3].Text; lstExclusions.SelectedItems[0].SubItems[4].Text = listItem.SubItems[4].Text; SetButtonState(); } } this.DialogResult = DialogResult.None; }
/// <summary> /// Add a new exclusion item. /// </summary> /// <param name="sender">system parameter</param> /// <param name="e">system parameter</param> private void btnAdd_Click(object sender, EventArgs e) { var dlg = new frmAddEditExclusions(GetCurrentFilterItems(), null); if (dlg.ShowDialog(this) == DialogResult.OK) { // create new entry lstExclusions.Items.Add(GetListViewItem(dlg.CurrentItem)); SetButtonState(); } this.DialogResult = DialogResult.None; }