# For each loop not creating and add child to widget. But the array is working.

**URL:** <https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, bug-report, Blueprint, question\
**Created:** [May 23, 2024, 2:30am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546 "2024-05-23T02:30:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ColicPizza\_4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ColicPizza\_4](https://forums.unrealengine.com/u/ColicPizza_4)\
**Post date:** [May 23, 2024, 2:30am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546/1 "2024-05-23T02:30:50Z")

</div>

[Blueprints]I am using UE 5.1 and made an inventory system. When i implemented a transfer feature to this system. The ui implementation would not work. But it was not the for each loop not working the loop is increase it array index for each item in the context i have. But after the child is not added to the ui grid list. I am using the slots as a button to activate the transfer and these items are being added to my inventory. yet only the first slot appears and i have to close the ui and open it up again and then they appears.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/6/776625c52e88f88bbed40b981ab6518947d442b9.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/a/5/aa5eeb558f69924af0651b20f602b7a6d5fcbaab.jpeg)  
FRIST ITEM  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/e/e/2eef188571352220c6d4cfc3309008ac2da5b478.jpeg)  
Second item which is an apple  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/2/a/a2a2cbc6c2c05fa6330bce6a67b21618c88ebc6b.jpeg)

---

<div class="post-metadata">

**Author:** ![ColicPizza\_4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ColicPizza\_4](https://forums.unrealengine.com/u/ColicPizza_4)\
**Post date:** [May 23, 2024, 3:36am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546/2 "2024-05-23T03:36:35Z")

</div>

And when i reopen it

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/8/7/78718de41cb30b95069c24cd4d40c236cf3f9679.jpeg)

---

<div class="post-metadata">

**Author:** ![ColicPizza\_4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ColicPizza\_4](https://forums.unrealengine.com/u/ColicPizza_4)\
**Post date:** [May 23, 2024, 4:27am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546/3 "2024-05-23T04:27:20Z")

</div>

Fix Problem  
I was using a Grid Panel. It seams that you can’t create new Grid slots during run time. I replaced all references with a Vertical Box that has solved my problem.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [May 23, 2024, 7:45am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546/4 "2024-05-23T07:45:15Z")

</div>

> [@ColicPizza\_4](#):
>
> you can’t create new Grid slots during run time

You can, you need to feed it column and row:

> [@Uniform Grid Panel setup](https://forums.unrealengine.com/t/uniform-grid-panel-setup/89025/2):
>
> Welcome to the forums. If you want a widget to have a specific size, you can place it on a canvas; in addition, this will allow you to control its position (amongst other things). Here is an example of a \*UniformGrid \*sitting on the canvas (inside a border to make it pretty). The grid widget: When you add children to a \*UniformGrid \*you’ll need to specify which column & row they occupy. If you add children manually, you can set it up in the details panel of every child (as default…

* * *

You could also use a Wrap Box which would automatically create a Grid like layout providing it exceeds container desired size.

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [June 22, 2024, 7:45am UTC](https://forums.unrealengine.com/t/for-each-loop-not-creating-and-add-child-to-widget-but-the-array-is-working/1868546/5 "2024-06-22T07:45:51Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
