Example #1
0
        private void editPersonToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var personForm = new PersonForm((Person)listView1.SelectedItems[0].Tag);

            personForm.ShowDialog(this);

            if (personForm.DialogResult == DialogResult.OK)
            {
                var savedPerson = personForm.GetPerson();
                listView1.Items.Clear();
                foreach (var person in people)
                {
                    ListViewItem item = new ListViewItem
                    {
                        Text = person.Name,
                        Tag  = person
                    };
                    item.SubItems.Add(person.LastName);
                    listView1.Items.Add(item);
                }
                personForm.Dispose();
            }
            else
            {
                personForm.Dispose();
            }
        }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var personForm = new PersonForm();

            personForm.ShowDialog(this);

            if (personForm.DialogResult == DialogResult.OK)
            {
                var savedPerson = personForm.GetPerson();
                people.Add(savedPerson);
                listView1.Items.Clear();
                foreach (var person in people)
                {
                    ListViewItem item = new ListViewItem
                    {
                        Tag = person
                    };
                    item.SubItems.Add(person.LastName);
                    listView1.Items.Add(item);
                }
                personForm.Dispose();
            }
            else
            {
                personForm.Dispose();
            }
        }