anuka93
anuka93

Reputation: 74

Adding a Widget with a total height in gtk#

I am adding a list of widgets programatically to an VBox container. That works fine, but the widgets, I add, will take the whole window size, so that they are quite big if I have only a few elements. I want them to be allways the same size despite the size of the window.

I tried for setting SizeRequest, but that only worked as minimum size. Than I put the Widget in a Fixed Container and added that to the VBox. Well that helped fixing the height, but it fixed also the width. And the widgets are not set beneath each other, but have still a spacing, as if they were still as big as before.

How can I fix the total height of a widget or the height of the Container parts?

Upvotes: 1

Views: 917

Answers (1)

anuka93
anuka93

Reputation: 74

Well the Solution was understanding packing of boxes.

This website explains it well: http://www.mono-project.com/docs/gui/gtksharp/widgets/packing-with-boxes/

First I had to set a SizeRequest and put my Item inside an Alignment Container. Instead of adding the container to the VBox via Add(), I had to Add it with PackStart() and disable expanding and filling.

var algn = new Alignment(0,0,0,0);
item.SetSizeRequest (300, 40); //item is the control I want to add
algn.Add (item);
list.PackStart (algn,false,false,0); //list is the VBox

Upvotes: 2

Related Questions