private void buttonEditKey_Click(object sender, EventArgs e)
 {
     Key key = (Key)listBoxKeys.SelectedItem;
     KeyDialog keyd = new KeyDialog(objects, key);
     DialogResult result = keyd.ShowDialog();
     if (result == DialogResult.OK)
     {
         // update the key
         selectedType.keys.Remove(key);
         key.KeyType.keys.Add(key);
         key.Save();
         PopulateTypes();
         SelectAndExpand(key.KeyType);
     }
     keyd.Dispose();
 }
 private void buttonCreateCopy_Click(object sender, EventArgs e)
 {
     // open a form to create a key
     KeyDialog keyd = new KeyDialog(objects);
     DialogResult result = keyd.ShowDialog();
     if (result == DialogResult.OK)
     {
         // create the key
         Key key = keyd.key;
         key.KeyType.keys.Add(key);
         objects.keys.Add(key);
         key.Save();
         PopulateTypes();
         SelectAndExpand(key.KeyType);
     }
     keyd.Dispose();
 }