'mode 1 width,2 height
Public Sub setLblWrapContent(lbl As Label,mode As Int)
Dim h,w,ow,oh As Double
ow=lbl.Width
oh=lbl.Height
h=MeasureText(lbl,lbl.Text)(1)
w=MeasureText(lbl,lbl.Text)(0)
If mode=1 Then
lbl.Width=h*w/oh
Else
lbl.Height=h*w/ow
End If
lbl.SizeToFit
End Sub
Sub MeasureText(lbl As Label,txt As String) As Double()
lbl.Text=txt
lbl.SizeToFit
Dim Result(2) As Double
Result(0) = lbl.Width
Result(1) = lbl.Height
Return Result
End Sub