How to change the way items are arranged in a GridContainer?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Haseb

Items are arranged in a 2-column GridContainer like this:

Item1 Item2
Item3 Item4

Can I have them arranged like this?:

Item1 Item5

:bust_in_silhouette: Reply From: Zylann

If you want “holes” in a GridContainers, you can add empty Control nodes to fill them. I use this commonly as “spacers”, to create artificial space between controls when using containers.

Another way is to use two containers: one for your first line, and one for the column after it.

Not sure you got me right… I want to fill up the first column first, and once it’s filled up, go to the second column.

Haseb | 2019-03-29 14:33

Oh, I see. I looks like there is no option to do this. You could do a feature request to ask for that option.
A workaround would be to use a HBoxContainer, in which you put a VBoxContainer for each column you want. Or you could write your own GridContainer by writing a script extending Container.

Zylann | 2019-03-29 20:28

I’m writing my own one from scratch. Turns out it’s not that hard. Thank you!

Haseb | 2019-03-29 20:32

I would like to see what you did here.

How did you write it from scratch? I don’t know where to begin.

hungLink | 2022-12-04 19:30

:bust_in_silhouette: Reply From: medex81

If you don’t want override order method from the GridContainer set property column to one in settings and in a script increment him if child_count equal you raw count.