[Gambas-user] TableView Lacking Alignment Function

Rolf-Werner Eilert eilert-sprachen at ...221...
Thu Nov 17 08:52:03 CET 2011


Am 16.11.2011 16:23, schrieb Randy Millner:
> Hello Rolf, thanks for the reply,
> I tried manually declaring padded whitespace. Example:
> TableView1.Columns[7].Title = "         Amount"
> And the result was only one space being delivered to the final output:
> " Amount"
> What would be different if I wrote a function?

Oops - I guess nothing :-)

But - err - hm. Ok, trying it myself...

PRIVATE FUNCTION rightbound(column AS Integer, text AS String) AS String

   IF tbk.Font.Width(text) >= tbk.Columns[column].Width THEN RETURN text

   DO
     text = " " & text
   LOOP UNTIL tbk.Font.Width(text) >= tbk.Columns[column].Width - 10

   RETURN text

END

Then I called this with

tbk.Columns[1].Text = rightbound(1, "Text")

In the program I tried this tbk is the name of the TableView. And it 
turned out to be fine with Width -10, otherwise it stops too late.

Does it run for you too? Anyway, this way you have a dynamic thing that 
you can call if a user changes the column's width.

Rolf




More information about the User mailing list