Height of Multiline Textfield in Report

Hi,

I want to have a multiline textfield in a report.
To know the height of this textfield (and the report body), I need the number of lines, this is dynamic.
I tried to find out the text width, but with canvas, etc. I get totally other results that printed with the report.
Anyone who managed this?

Marius

Maybe you can use a canvas instead? Draw the text using word wrap and calculate the final height.

[quote=231942:@Marius Dieter Noetzel]Hi,

I want to have a multiline textfield in a report.
To know the height of this textfield (and the report body), I need the number of lines, this is dynamic.
I tried to find out the text width, but with canvas, etc. I get totally other results that printed with the report.
Anyone who managed this?

Marius[/quote]

I suppose you have already tried Graphics.StringHeight ?

Marius, I was reading your question wrong on my phone earlier.
What do you need exactly? The subject says that you want the height of a multiline textfield. What is a multiline textfield? Do you mean a Textarea? Or a Multiline Label?

Further in you message you say that you need the number of lines. That is something else.

  • If you need to know the number of lines in a Multiline Label, you can use something like this Extend:
Function NumLines(Extends lbl As Label) As Integer
  Dim p As New Picture(lbl.Width, lbl.Height)
  p.Graphics.TextSize = lbl.TextSize
  p.Graphics.TextFont = lbl.TextFont
  Return (p.Graphics.StringHeight(lbl.Text, lbl.width)) / (p.Graphics.StringHeight("I", 999))
End Function
  • If you’re talking about a Textarea, it depends.
    If you want the TextArea lines based on the EndOfLine’s, then do something like this: Lines = CountFields(TextArea1.Text, EndOfLine)
    If you want the TextArea lines based on wordwrap, something like the above Label Extend will work but not if the text is formatted.

  • If you want the height of the text, use StringHeight as in the Label Extend example.