[Gambas-user] Label control

Bruce Steers bsteers4 at gmail.com
Wed Jun 15 01:00:30 CEST 2022

Have a look at Paint.TrimText

Works something like this (may need a tweak)...

Public TrimText(ctrl as control, txt as string, length as integer) As String
Dim sOut As string
Dim iPos As integer = 1

While sOut <> txt
  sOut &= Mid(txt, iPos, 1)
  If ctrl.Font.TextWidth(sOut & "...") > length Then Return sOut &"..."
  Inc iPos

Return sOut



On Tue, 14 Jun 2022, 23:27 Steve via User, <user at lists.gambas-basic.org>

> I am attempting to populate a label control. The text on the control will
> vary. The size of the control does not. Is there a way to detect when the
> text Will overflow the control so that I can split the text up properly to
> display? This would be in the case where there is sufficient vertical room
> but not horizontal. Also the font size will vary.
> Get TypeApp for Android <http://www.typeapp.com/r>
> ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20220615/13e20951/attachment.htm>

More information about the User mailing list