Ejemplo n.º 1
0
        private void addBt_Click(object sender, EventArgs e)
        {
            var epdlg = new EditPersonForm("添加", new Person(""));

            epdlg.StartPosition = FormStartPosition.CenterParent;
            if (epdlg.ShowDialog() == DialogResult.OK)
            {
                persons.Add(epdlg.Person);
                this.personsLv.VirtualListSize = persons.Count;
                personsLv.Invalidate();
            }
        }
Ejemplo n.º 2
0
        private void updateBt_Click(object sender, EventArgs e)
        {
            int index;

            try
            {
                index = personsLv.SelectedIndices[0];
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("{0}", ex.Message);
                return;
            }
            string name    = persons.GetPerson(index).Name;
            Person tperson = new Person(persons.GetPerson(index).Name, persons.GetPerson(index).Text, persons.GetPerson(index).Picpath);
            var    epdlg   = new EditPersonForm("修改", tperson);

            epdlg.StartPosition = FormStartPosition.CenterParent;
            if (epdlg.ShowDialog() == DialogResult.OK)
            {
                persons.UpdatePerson(index, tperson);
                personsLv.Invalidate();
            }
        }