Пример #1
0
        void EditClick(object sender, EventArgs e)
        {
            if (listView1.SelectedItems.Count == 0)
            {
                return;
            }

            var    item       = listView1.SelectedItems[0];
            Author editAuthor = new Author(
                item.Text,
                item.SubItems[1].Text,
                item.SubItems[2].Text,
                item.SubItems[3].Text
                );

            var form = new AuthorForm(editAuthor);

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            item.Text             = editAuthor.name;
            item.SubItems[1].Text = editAuthor.email;
            item.SubItems[2].Text = editAuthor.homepage;
            item.SubItems[3].Text = editAuthor.role;
        }
Пример #2
0
        void AddClick(object sender, EventArgs e)
        {
            Author newAuthor = new Author();

            var form = new AuthorForm(newAuthor);

            if (form.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            var item = new ListViewItem(newAuthor.name);

            item.SubItems.Add(newAuthor.email);
            item.SubItems.Add(newAuthor.homepage);
            item.SubItems.Add(newAuthor.role);
            listView1.Items.Add(item);
        }