Exemplo n.º 1
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (listView.CheckedItems.Count <= 0) return;

            FormMember form = new FormMember();
            foreach (ListViewItem item in listView.CheckedItems)
            {
                var member = (Member) item.Tag;

                // Fill form with actual member data.
                form.FirstName = member.FirstName;
                form.LastName = member.LastName;
                form.Image = member.Image;
                form.Group = member.Group;

                if (form.ShowDialog() != DialogResult.OK) continue;

                // Update member object.
                member.FirstName = form.FirstName;
                member.LastName = form.LastName;
                member.Image = form.Image;
                member.Group = form.Group;
                if (member.Group != null)
                {
                    Group.Groups.ForEach(g => g.Members.Remove(member));
                    member.Group.Members.Add(member);
                }

                // Updatge list item.
                item.SubItems[1].Text = form.FirstName + ' ' + form.LastName;
                if (member.Group != null) item.SubItems[2].Text = member.Group.Name;
            }
        }
Exemplo n.º 2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            using (var popup = new FormMember())
            {
                if (popup.ShowDialog() != DialogResult.OK) return;

                var member = new Member(popup.FirstName, popup.LastName, popup.Image);
                Member.Members.Add(member);
                member.Group = popup.Group;
                RefreshList();
            }
        }