Hey guys, i have a question, I would like give the textbox a dynamic height
like this:
I fail because the textbox then always disappears down.
has anyone ever done this?
this is my code:
like this:
I fail because the textbox then always disappears down.
has anyone ever done this?
this is my code:
B4X:
Sub IndexOfNth(s As String, SearchFor As String, Count As Int) As Int
Dim res As Int = -1
For i = 0 To Count - 1
res = s.IndexOf2(SearchFor, res + 1)
If res = -1 Then Return -1
Next
Return res
End Sub
Sub txb_content_TextChanged (Old As String, New As String)
Dim hoehe As Object
hoehe = su.MeasureMultilineTextHeight(txb_content,txb_content.Text )
Dim i As Int = IndexOfNth(txb_content.text, CRLF, 5)
If i < 1 Then
txb_content.Height = hoehe + 20dip
pnl_ground.Height = hoehe + 20dip
'pnl_ground.Top = pnltop + 20dip
Else If i < 2 And i > 1 Then
txb_content.Height = hoehe + 20dip
pnl_ground.Height = hoehe + 20dip
'pnl_ground.Top = pnltop + 40dip
Else If i < 3 And i > 2 Then
txb_content.Height = hoehe + 20dip
pnl_ground.Height = hoehe + 20dip
' pnl_ground.Top = pnltop + 60dip
Else If i < 4 And i > 3 Then
txb_content.Height = hoehe + 20dip
pnl_ground.Height = hoehe + 20dip
' pnl_ground.Top = pnltop + 80dip
Else If i < 5 And i > 4 Then
txb_content.Height = hoehe + 20dip
pnl_ground.Height = hoehe + 20dip
'pnl_ground.Top = pnltop + 100dip
End If
End Sub
Last edited: