In cases where the text property of a control, such as a label, is dynamic, it would be useful to be able to resize the control to fit the text. The preferred way to do this would be to add a new function such as the one below to calculate a control’s dimensions based on its Text field:
To calculate width and height:
An alternative to this would be to have an AutoResizeWidth and AutoResizeHeight property on controls that when turned on, automatically resizes the control to its appropriate dimensions. However, this would be less flexible and IMHO less elegant than a function such as the one above.