# FlexibleGrid column sizing

**URL:** <https://www.ruby-forum.com/t/flexiblegrid-column-sizing/165891>\
**Category:** wxRuby\
**Created:** [April 19, 2009, 3:09am UTC](https://www.ruby-forum.com/t/flexiblegrid-column-sizing/165891 "2009-04-19T03:09:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [April 19, 2009, 3:09am UTC](https://www.ruby-forum.com/t/flexiblegrid-column-sizing/165891/1 "2009-04-19T03:09:40Z")

</div>

OK, I’m relatively new to wxruby, but have gotten a few forms  
successful, and so building up some experience, but have run into a  
major challenge with the following issue. I want to generate a  
table-like thing, that has a known number of columns, but a variable  
number of rows, but the number of rows will be 25 or less; all the rows  
are to be the same height, but the columns need to be all different  
widths.

So I was using a FlexGridSizer, set the number of columns and rows; I am  
able to put the sizer into a form and able to put controls into the  
FlexGrid control without any proble. However all the columns are the  
same width, and I can’t find any combination of flags that will make the  
the columns anything other than the width of the widest column. Most of  
the controls going into the grid are TextCtrls and I have specified the  
“maximum\_size” attribute as a Size.new(x,-1) with the following flags:  
ALIGN\_LEFT | ST\_NO\_AUTORESIZE. When adding the controls to the  
FlexGrid to “proportion” field is set to zero. And yet all the columns  
are the same width, the width of the widest sub-control.

How can one specify a maximum column size? How does one have a FlexGrid  
recompute the column widths? Is FlexGrid the wrong thing to do this  
with?

---

<div class="post-metadata">

**Author:** ![mike343](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/58f4c7/32.png) [@mike343](https://www.ruby-forum.com/u/mike343)\
**Post date:** [April 20, 2009, 12:45am UTC](https://www.ruby-forum.com/t/flexiblegrid-column-sizing/165891/2 "2009-04-20T00:45:18Z")

</div>

Hi

Michael M. wrote:

> FlexGrid control without any proble. However all the columns are the  
> with?

You probably want to call FlexGridSizer#add\_growable\_col with a  
proportion \> 0 on at least one column in the sizer. That column will  
then receive available additional space, and the other columns will have  
the minimum size for their controls.

If all proportions == 0, the available space is distributed evenly  
between all columns:

[http://wxruby.rubyforge.org/doc/flexgridsizer.html#FlexGridSizer\_addgrowablecol](http://wxruby.rubyforge.org/doc/flexgridsizer.html#FlexGridSizer_addgrowablecol)

a
