private void IndentificationNumbersListControl_OnEdit() { if (SelectedItems.Count > 0) { var id = (IdentificationNumber)SelectedItems[0].Tag; var form = new IdentificationNumberForm(); form.IdentificationNumber = id; RegisterForm(form); form.Closed += delegate(object sndr, EventArgs ee) { IdentificationNumberForm frm = sndr as IdentificationNumberForm; UnRegisterForm(frm); if (DialogResult.OK == frm.DialogResult) { id = frm.IdentificationNumber; String idType = ""; if (id is ManufacturerIdentificationNumber) { idType = "MFR"; } else if (id is UserDefinedIdentificationNumber) { idType = "USR"; } ListViewItem lvi = SelectedItems[0]; lvi.SubItems[0].Text = idType; lvi.SubItems[1].Text = id.number; lvi.SubItems[2].Text = id.type.ToString(); lvi.SubItems[3].Text = id is UserDefinedIdentificationNumber ? ((UserDefinedIdentificationNumber)id).qualifier : ""; if (id is ManufacturerIdentificationNumber) { lvi.SubItems[4].Text = ((ManufacturerIdentificationNumber)id).manufacturerName; } else { lvi.SubItems[4].Text = ""; } lvi.Tag = id; } }; form.Show(); } }
private void IndentificationNumbersListControl_OnAdd() { var form = new IdentificationNumberForm(); form.IdentificationNumber = new IdentificationNumber(); if (DialogResult.OK == form.ShowDialog()) { IdentificationNumber id = form.IdentificationNumber; String idType = ""; if (id is ManufacturerIdentificationNumber) { idType = "MFR"; } else if (id is UserDefinedIdentificationNumber) { idType = "USR"; } var lvi = new ListViewItem(idType); lvi.SubItems.Add(id.number); lvi.SubItems.Add(id.type.ToString()); lvi.SubItems.Add(id is UserDefinedIdentificationNumber ? ((UserDefinedIdentificationNumber)id).qualifier : ""); if (id is ManufacturerIdentificationNumber) { lvi.SubItems.Add(((ManufacturerIdentificationNumber)id).manufacturerName); } else { lvi.SubItems.Add(""); } lvi.Tag = id; Items.Add(lvi); if (_identificationNumbers == null) { _identificationNumbers = new List <IdentificationNumber>(); } _identificationNumbers.Add(id); lvi.BackColor = lvi.Index % 2 == 0 ? ATMLContext.COLOR_LIST_EVEN : ATMLContext.COLOR_LIST_ODD; } }