PDA

View Full Version : Auto column width in grid?



timefortea
16 Jan 2009, 6:25 AM
I have a grid which will contain an unknown number of columns - is it possible to have the grid automatically size these so that they fill up the width allocated to the grid? I don't want to use setAutoExpandColumn as each column could contain anything. Ultimately I'd like to have the grid size all the columns according to the size of items in each one (eg. if the text in column one is longer than in column two, then two is smaller than one and overall they fill the space of the grid), but anything at all would be nice. At the minute I can only give each column a fixed width, which isn't much use because the number of columns varies and the window size can vary. I thought that if I divided the grid or panel width by the number of columns, I could do something with that, but calling getWidth() just returns 0.

Any ideas?

Thanks.