private void btnRemove_Click(object sender, EventArgs e)
        {
            if (listGear.SelectedItems.Count > 0)
            {
                Gear gearToDelete = new Gear();
                gearToDelete = (Gear)listGear.SelectedItems[0];
                foreach (Gear g in Program.gearList)
                {
                    if (g.Equals(gearToDelete))
                    {
                        gearToDelete = g;
                    }
                }
                Program.gearList.Remove(gearToDelete);
                Database1DataSet1TableAdapters.GearsTableAdapter gta = new Database1DataSet1TableAdapters.GearsTableAdapter();
                gta.Delete(gearToDelete.ID, gearToDelete.Name, gearToDelete.Alpha, gearToDelete.GearModule, gearToDelete.Material.ID, gearToDelete.Torque, gearToDelete.Shaft.ID, gearToDelete.WantedRadius, gearToDelete.Z, gearToDelete.Phi, gearToDelete.R_base, gearToDelete.R_foot, gearToDelete.R_pitch, gearToDelete.R_top);

            }
            refreshList();
            treeViewGear.Nodes.Clear();
            propertyGridGear.SelectedObject = null;
            btnRemove.Enabled = false;
            btnEdit.Enabled = false;
            btnSelect.Enabled = false;
        }
        private void btnRemove_Click_1(object sender, EventArgs e)
        {
            if (DialogResult.OK == MessageBox.Show("You may delete Gear Boxes associated. Do you want to continue ?", "Caution", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
            {
                if (listGear.SelectedItems.Count > 0)
                {
                    Gear gearToDelete = new Gear();
                    gearToDelete = (Gear)listGear.SelectedItems[0];

                    Program.gearList.Remove(gearToDelete);
                    Database1DataSet1TableAdapters.GearsTableAdapter gta = new Database1DataSet1TableAdapters.GearsTableAdapter();
                    Database1DataSet1TableAdapters.GearBoxTableAdapter gbta = new Database1DataSet1TableAdapters.GearBoxTableAdapter();

                    try
                    {
                        gbta.DeleteInputGearQuery(gearToDelete.ID);
                        gbta.DeleteOutputGearQuery(gearToDelete.ID);
                        gta.Delete(gearToDelete.ID, gearToDelete.Name, gearToDelete.Alpha, gearToDelete.GearModule, gearToDelete.Material.ID, gearToDelete.Torque, gearToDelete.Shaft.ID, gearToDelete.WantedRadius, gearToDelete.Z, gearToDelete.Phi, gearToDelete.R_base, gearToDelete.R_foot, gearToDelete.R_pitch, gearToDelete.R_top);
                        Util.refreshGearBoxList();
                    }
                    catch (Exception ex) { }

                }
                refreshList();
                propertyGridGear.SelectedObject = null;
                btnRemove.Enabled = false;
                btnEdit.Enabled = false;
                btnSelect.Enabled = false;
            }
        }