private void button2_Click(object sender, EventArgs e) { if (personsListView.SelectedIndices.Count == 0) { return; } Person p = pers[personsListView.SelectedIndices[0]]; EditPersonForm editForm = new EditPersonForm(p); if (editForm.ShowDialog() == DialogResult.OK) { personsListView.Invalidate(); } }
private void button1_Click(object sender, EventArgs e) { Person p = new Person(); EditPersonForm editForm = new EditPersonForm(p); if (editForm.ShowDialog() != DialogResult.OK) { return; } //ListViewItem newItem = personsListView.Add(editForm.FirstName); //newItem.SubItems.Add(editForm.Name); //newItem.SubItems.Add(editForm.LastName); //newItem.SubItems.Add(editForm.Age.ToString()); personsListView.RetrieveVirtualItem += new RetrieveVirtualItemEventHandler(personsListView_RetrieveVirtualItem); pers.Add(p); personsListView.VirtualListSize = pers.Count; personsListView.Invalidate(); }