[Gambas-user] Gambas-user Digest, Vol 66, Issue 27

Fabien Bodard gambas.fr at ...626...
Sat Nov 19 07:06:33 CET 2011


2011/11/18 Randy Millner <randlemillner at ...626...>:
> Hello Rolf,
> I am grateful for your assistance.
> I was confused.
> I saw nowhere in your function referencing .title?
> I changed text to title
>
> All is well!! Thank you!!!
>
>
>
>> Message: 5
>> Date: Thu, 17 Nov 2011 08:52:03 +0100
>> From: Rolf-Werner Eilert <eilert-sprachen at ...221...>
>> Subject: Re: [Gambas-user] TableView Lacking Alignment Function
>> To: gambas-user at lists.sourceforge.net
>> Message-ID: <4EC4BD23.20108 at ...221...>
>> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>>
>> 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...
>>

Short version

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

Return Space$(CInt(Int(((tbk.Columns[column].Width - 10) -
tbk.Font.TextWidth(text)) / tbk.font.textwidth(" ")))) & text

endif


>> 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
>>
>>
>>
>
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure
> contains a definitive record of customers, application performance,
> security threats, fraudulent activity, and more. Splunk takes this
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Fabien Bodard




More information about the User mailing list