Clearing or Rebuilding a GridLayoutGroup

Hey all, I have created a GridLayoutGroup called RecruitGrid as seen in the code below.

When someone clicks the button, I want the both the _soldier from the list removed as well as the GridLayoutGroup instantiated prefab Item. I know how to destroy the grid item and remove the _soldier object from list, but I need to also refresh or rebuild the GridLayoutGroup afterward.

Here’s the code for the grid:

    public void OpenTavern()
    {
        // list available recruits
        foreach (Soldier _soldier in SelectedSettlement.UnitsAvailableForRecruitment)
        {
            // instantiate and set up prefab in grid
            GameObject _recruitPrefab = Instantiate(Resources.Load("RecruitBox")) as GameObject;
            _recruitPrefab.transform.SetParent(RecruitGrid.transform, false);
            _recruitPrefab.transform.localPosition = Vector3.zero;

            // populate prefab with recruit info
            RecruitBox _recruitInfo = _recruitPrefab.GetComponent<RecruitBox>();
            _recruitInfo.NameLabel.text = _soldier.unitName;
            _recruitInfo.RecruitButton.onClick.AddListener(() => RecruitSoldier(_soldier, _recruitPrefab));
        }
    }

And here is the code for the button, where I destroy the object, remove the soldier from the list, and then re-open the method containing the GridLayoutGroup:

    public void RecruitSoldier(Soldier _soldier, GameObject _object)
    {
        SelectedPlayerParty.UnitsAttached.Add(_soldier);
        SelectedSettlement.UnitsAvailableForRecruitment.Remove(_soldier);
        Destroy(_object);
        
        OpenTavern();
    }

Currently, reopening the OpenTavern() method just adds the remaining soldiers to the GridLayoutGroup. I want to rebuild the GridLayoutGroup from scratch whenever OpenTavern() is called. I’ve searched on this for a while now with no luck - any answers would be greatly appreciated!

After spending hours on this, I found the solution less than a minute after posting this:

        for (int i = 0; i < RecruitGrid.transform.childCount; i++)
            Destroy(RecruitGrid.transform.GetChild(i).gameObject);

Sorry for the bother. Hopefully this helps someone else down the line!