Beispiel #1
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            EditPersonForm editForm = new EditPersonForm();

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            ListViewItem newItem = personListView.Items.Add(editForm.FirstName);

            newItem.SubItems.Add(editForm.LastName);
            newItem.SubItems.Add(editForm.Age.ToString());
        }
Beispiel #2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (personListView.SelectedItems.Count == 0)
            {
                return;
            }
            ListViewItem   item     = personListView.SelectedItems[0];
            EditPersonForm editForm = new EditPersonForm();

            editForm.FirstName = item.Text;
            editForm.LastName  = item.SubItems[1].Text;
            editForm.Age       = Convert.ToInt32(item.SubItems[2].Text);

            if (editForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            item.Text             = editForm.FirstName;
            item.SubItems[1].Text = editForm.LastName;
            item.SubItems[2].Text = editForm.Age.ToString();
        }