Beispiel #1
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     //  Create the new item form.
     var form = new ExtensionSwitchForm() {Text = "New Extension Switch"};
     if (form.ShowDialog(this) == DialogResult.OK)
     {
         listViewExtensionSwitches.Items.Add(new ListViewItem(new[] {form.From, form.To}));
         SaveChanges();
     }
 }
Beispiel #2
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            //  Create the new item form.
            var form = new ExtensionSwitchForm()
            {
                Text = "New Extension Switch"
            };

            if (form.ShowDialog(this) == DialogResult.OK)
            {
                listViewExtensionSwitches.Items.Add(new ListViewItem(new[] { form.From, form.To }));
                SaveChanges();
            }
        }
Beispiel #3
0
 private void buttonEdit_Click(object sender, EventArgs e)
 {
     //  Get the first selected item.
     var item = listViewExtensionSwitches.SelectedItems.OfType<ListViewItem>().FirstOrDefault();
     if (item != null)
     {
         //  Create the new item form.
         var form = new ExtensionSwitchForm() { Text = "Edit Extension Switch", From = item.SubItems[0].Text, To = item.SubItems[1].Text};
         if (form.ShowDialog(this) == DialogResult.OK)
         {
             item.SubItems[0].Text = form.From;
             item.SubItems[1].Text = form.To;
             SaveChanges();
         }
     }
 }
Beispiel #4
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            //  Get the first selected item.
            var item = listViewExtensionSwitches.SelectedItems.OfType <ListViewItem>().FirstOrDefault();

            if (item != null)
            {
                //  Create the new item form.
                var form = new ExtensionSwitchForm()
                {
                    Text = "Edit Extension Switch", From = item.SubItems[0].Text, To = item.SubItems[1].Text
                };
                if (form.ShowDialog(this) == DialogResult.OK)
                {
                    item.SubItems[0].Text = form.From;
                    item.SubItems[1].Text = form.To;
                    SaveChanges();
                }
            }
        }