textarea line count
Posted
#1
(In Topic #789)
Regular

Knowing the number of lines displayed would be a help.
Any ideas?
Posted
Guru

bill-lancaster said
I'd like to adjust the height of a textarea (with Wrap = TRUE) so that all the text is displayed.
Knowing the number of lines displayed would be a help.
Any ideas?
the height should be..
Code (gambas)
But add an extra bit (line height) for the border/margin..
or to specifically answer your question on how to get the visible lines then..
Posted
Guru

Trouble with using RichTextHeight is TextArea is not RichRext
A TextLabel is RichText and has AutoResize and will give better results for RichtextHeight than a TextArea will
Posted
Regular

I want the displayed text to be editable so I think I'm stuck with textarea.
Bill
Posted
Trainee
Code
Dim totalLines As Integer
'move cursor to last position (the end) of text area
TextArea1.CursorAt(TextArea1.Length)
'get total lines from last line number in text area
totalLines = TextArea1.LineWith autowrap turned on, you may have to hunt the text for linefeed or carriage return codes to come up with a better number because a line that is auto-wrapped will appear on-screen as multiple lines, but the line count from the code will think both are the same line. In other words, a long line 20 that is wrapped will return line 20 on both "lines" of the display. Also, the line counting starts with line 0, if I remember correctly.
I use a version of this to paginate a printout on a little text editor app. Hope it helps.
-hink
1 guest and 0 members have just viewed this.


