public void MenuDelete_Click(object sender, EventArgs e) { if (parent.flpCurrent == MainForm.flpItems.Custom) { string fp = JsonFunctions.GetFilepath(CustomForm.foodFile); CustomForm.RemoveCustomFood(fp, food); parent.PopulateResults(CustomForm.GetCustomFood(fp), edit, rightClick); } else if (parent.flpCurrent == MainForm.flpItems.Eaten) { List <User> users = FoodForm.GetAllUsers(); User user = users.Find(x => x.id == parent.currentUser.id); int i = users.IndexOf(user); int foodIndex = user.food_eaten.FindIndex(x => x.item_id == food.item_id); if (foodIndex != -1) { user.food_eaten.RemoveAt(foodIndex); user.eaten_cal = user.EatenCal(); users[i] = user; JsonFunctions.WriteJSON(users, JsonFunctions.GetFilepath(UserForm.filename)); parent.currentUser = user; parent.SetCalories(); parent.PopulateResults(user.food_eaten, edit, rightClick); } } else if (parent.flpCurrent == MainForm.flpItems.Search) { return; } }