Ejemplo n.º 1
0
        private void AddNewItem()
        {
            Attachment         newAttachment = new Attachment();
            EditAttachmentForm form          = new EditAttachmentForm(newAttachment);

            if (form.ShowDialog() == DialogResult.OK)
            {
                AddAttachment(newAttachment);
            }
        }
Ejemplo n.º 2
0
        private void EditSelectedItem()
        {
            ListView.SelectedListViewItemCollection items = AttachmentsListView.SelectedItems;
            if (items.Count > 1)
            {
                MessageBox.Show("You can only edit one item at the same time.");
                return;
            }

            ObjectListViewItem lvi = items[0] as ObjectListViewItem;
            Attachment         underlyingObject = lvi?.UnderlyingObject as Attachment;

            if (underlyingObject != null)
            {
                Attachment         copy = underlyingObject.Copy();
                EditAttachmentForm form = new EditAttachmentForm(copy);
                if (form.ShowDialog() == DialogResult.OK)
                {
                    copy.CopyTo(underlyingObject);
                    lvi.SubItems[0].Text = underlyingObject.Name;
                }
            }
        }