[Gambas-user] Gridview Q and determining width of a string
Richard Terry
rterry at ...1823...
Fri Jun 1 13:55:27 CEST 2012
Rolf-Werner Eilert wrote:
> Hi Richard,
>
>
>
>> 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.
>>
>
> Yes and no :-)
>
> To adjust the width, use Table.Font.Width(LongestString), maybe with a
> for-next loop at first to check the contents of all cells in a column,
> delivering a pointer to the longest string. As far as I understand, the
> Table (or Grid) has one font only, so it can be easily set this way.
> Correct me if I'm wrong.
>
> The WordWrap feature is switched on in one of my projects here, but I
> cannot find where quickly. Maybe I simply switched it on in the IDE as a
> default. Anyway, I'm having difficulties with the height of the line as
> it is not adapted automatically (at least this is my problem in Gambas2,
> I don't know how this is in Gambas3 yet).
>
> In this context I really like your idea with the label though the way
> you use it is not necessary as you have Table.Font.Width to do this:
>
>
>> 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.
>>
>
> But I could imagine it useful for wrapping the text AND find out how
> many rows of text result from it, setting the Height property for the row.
>
> Rolf
>
>
Hi Rolf,
thanks for your reply, I tried the font.width property, had to had 10 to
it to make it wide enough but it works well enough.
I found the wrap property so will experiment and report back over the
weekend (later night now in AU and only just sat down at the puter!.
richard
More information about the User
mailing list