Xojo equivalent for 'can grow' and 'can shrink' properties in MS Access

I’m new to Xojo, but have done a fiar bit of MS Access development over the years.
I need to display a piece of text that’s more than a single line, but I don’t know in advance how long it will be. In MS Access, I could specify the control (or screen section) as 'can grow = yes, can shrink = yes, and the text box would magically expand/contract to be big enough/small enough to display its contents.

Is there an equivalent way of achieving the same effect in Xojo?

Many thanks


No. You would have to put something in the FocusLost event (if you want it to resize as you lave the control) or TextChanged event (if you want it to change on every keypress). In there you would have to calculate the width of the text and adjust the width of the control accordingly. Equally for multi line text you would have to adjust the height of the control.

I think you have to set some code to get that in Xojo.

Try TextArea. You may need some additional code in order to adjust dimensions at runtime.

You would have to construct a picture, set the font characteristics of it’s graphics property and then use that to get the TextWidth or TextHeight for your text, applying those to the textbox:

' Assuming a textfield called TextField1
Var d As Double
Var p As New Picture(TextField1.Width, 100, 32)
d = p.Graphics.TextHeight(TextField1.Text, TextField1.Width)
TextField1.Height = d

That’s a start at least. I’ve not tried it and you may have to loop around the lines in your text field. It also assumes that you want to keep the width constant and vary the height.

You would also have to deal with any requirements for making the window size different, or moving other controls out of the way.

Thanks all!