[Gambas-user] Gridview Q and determining width of a string

Rolf-Werner Eilert eilert-sprachen at ...221...
Fri Jun 1 11:53:43 CEST 2012


Am 01.06.2012 00:27, schrieb Richard Terry:
> Hi List
>
> A few qridview questions if anyone has time.
>
> I'm loading a grid with variable length strings, and want to adjust the
> column widths to match, or have the option to increase the height of a
> cell with word-wrap within the cell.
>
> I wondered if anyone has gone down this path before.
>
> I tried having a hidden label with auto-resize = false, setting the
> label.text property to the string, reading the width, then setting the
> max width of all the strings to the column width. This works but seems
> messy, plus I found I had to put a Wait command after each label update
> or the label didn't resize.
>
> Also would be interested in how to wrap text within a grid cell.
>
> Regards
>
> richard

Ok, I just did some trial code, and it may run like this:

- Give a fixed Column.Width.
- Browse the strings and find out if Table.Font.Width(of the 
investigated Cell) is greater than the appropriate Column.Width.
- If yes: set the string into a TextLabel which has AutoResize = True 
and the Width of which is the same like Column.Width.
- Then read the resulting Height and give it to Table.Row.Height.

What do you think?

Rolf




More information about the User mailing list