Пример #1
0
        // The edit interface
        private void button2_Click(object sender, EventArgs e)
        {
            if (listView2.SelectedIndices.Count > 0)
            {
                // Edit selected

                // For every field in the editform, fill it with the corresponding listview field
                for (int i = listView2.Items.Count - 1; i >= 0; i--)
                {
                    if(listView2.Items[i].Selected) // This is the selected item
                    {
                        EditForm ef = new EditForm(this, listView2.Items[i]);
                        ef.Show();
                        //Let's fill the edit box with the selected item's data
                    }
                }
            }
            else
            {
                //Null selection form must be made
                NullSelectionForm ns = new NullSelectionForm();
                ns.Show();
            }
        }
Пример #2
0
        private void button3_Click(object sender, EventArgs e)
        {
            // Remove from ListView

            if (listView2.SelectedIndices.Count > 0)
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(@"a2entries.xml");

                XmlNodeList nodes = doc.GetElementsByTagName("entry");
                XmlNode toDel;

                for (int i = listView2.Items.Count - 1; i >= 0; i--)
                {
                    if (listView2.Items[i].Selected)
                    {
                        toDel = nodes[i];
                        if (toDel != null)
                        {
                            toDel.ParentNode.RemoveChild(toDel);
                        }
                        listView2.Items[i].Remove();
                    }
                }

                // Find the values of listView2.Items[i] and compare to Node, delete correct Node

                doc.Save("a2entries.xml");
            }
            else
            {
                //Null selection form must be made
                NullSelectionForm ns = new NullSelectionForm();
                ns.Show();
            }
        }